Java Spring Boot中的嵌套映射不加载静态内容
这就是我的html文件: getPass.htmlJava Spring Boot中的嵌套映射不加载静态内容,java,css,spring-mvc,uuid,get-request,Java,Css,Spring Mvc,Uuid,Get Request,这就是我的html文件: getPass.html PP安全 密码: 这是我的控制器: @RequestMapping("password/link/{enterId}") public ModelAndView getPasswordById(@PathVariable("enterId") UUID uuid) { ModelAndView mv = new ModelAndView(); if(passwordService.has
PP安全
密码:
这是我的控制器:
@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的
标记中。。。但我很想知道:
将UUID作为Get请求URL的端点是否有任何问题?我的意思是,在html文件中链接css文件会有问题吗
更新:
当我在@RequestMapping
中删除密码/link/
时,它正在工作,但是xzy/jkj/{id}有什么问题吗?已解决
我唯一需要的就是一个/
!!!!css的后面:th:href=“@{css/style.css}”
soth:href=“@{/css/style.css}”
究竟为什么它会在@GetMapping(“xxx”)
和@GetMapping(“嵌套的/xxx”)
之间产生差异