简体   繁体   English

为什么在向控制器添加路径变量时会阻止CSS和JS

[英]why when adding path variable to the controller it blocks css and js

I'm using @PathVariable to obtain some placeholder from the uri this is the function from my controller 我正在使用@PathVariable从uri获取一些占位符,这是我的控制器的功能

@RequestMapping(value = "/mail_detail/{id}", method = RequestMethod.GET)
public String showCourrierDetail(@PathVariable("id") String id) {
    //System.out.println("id="+id);
    return "mail_detail";
}

It redirects me to jsp page named mail_detail My problem is that when I add the path variable, the jsp page don't read the css files although when I use 它将我重定向到名为mail_detail的jsp页面。我的问题是,当我添加path变量时,尽管在使用时,jsp页面不会读取css文件

@RequestMapping(value = "/mail_detail", method = RequestMethod.GET)
public
 String showmail() {


    return "mail_detail";
}

It works and reads all the css files 它可以工作并读取所有的css文件

如果文件是jsp文件,则可以在URL中添加${pageContext.request.contextPath}前缀,例如<link href="${pageContext.request.contextPath}/resources/css/bootstrap.min.css" rel="stylesheet">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM