【发布时间】:2020-01-26 21:14:36
【问题描述】:
所以这是我的 html 文件:
getPass.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" type="image/jpg" href="../static/image/PUB_PIX_LION_K.jpg"
th:href="@{image/PUB_PIX_LION_K.jpg}">
<link href="../static/css/style.css" th:href="@{css/style.css}" rel="stylesheet" media="screen"/>
<title>PP-Secure</title>
</head>
<body>
<div class="wrapper-notification">
<h3>Password:</h3>
<p th:text="${dispPass}"></p>
<p th:text="${dispError}"></p>
</div>
</body>
</html>
这是我的控制器:
@RequestMapping("password/link/{enterId}")
public ModelAndView getPasswordById(@PathVariable("enterId") UUID uuid) {
ModelAndView mv = new ModelAndView();
if(passwordService.hasKey(uuid)) {
String passText = passwordService.getPassTextById(uuid).getPassText();
mv.addObject("dispPass",passText);
mv.setViewName("getPass");
} else {
String error = "No password available.";
mv.addObject("dispError",error);
mv.setViewName("getPass");
}
passwordService.removePasswordAfterVisit(uuid);
return mv;
}
问题是当我使用这个 URL(上述 @RequestMapping() 的参数)时,html 页面既不使用 .css(样式)也不使用 .jpg(浏览器选项卡中的徽标),所以我尝试了一切,最后写了测试映射:
@GetMapping("test")
public String showGetPass(){
return "getPass";
}
localhost:8080/test 一切正常,我的意思是徽标出现在浏览器选项卡中,样式来自 .css
所以我的快速解决方案是我将所有 .css 文件打包在 getPass.html 中的 <style></style> 标记中......但我很想知道:
将 UUID 作为获取请求的 URL 端点有什么问题吗?我的意思是,在 html 文件中链接 css 文件是否有问题?
更新:
当我在 @RequestMapping 中删除 password/link/ 时它正在工作,但是 xzy/jkj/{id} 有什么问题?
【问题讨论】:
标签: java css spring-mvc uuid get-request