admin管理员组文章数量:1390890
Here is a snippet of the paths I am using:
<link rel="stylesheet" type="text/templates.css" href="../templates/css/superfish.css" th:href="@{../templates/css/superfish.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/style.css" th:href="@{../templates/css/style.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/nivo-slider.css" th:href="@{../templates/css/nivo-slider.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery.qtip.min.css" th:href="@{../templates/css/jquery.qtip.min.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery-ui.css" th:href="@{../templates/css/jquery-ui.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery.fancybox.css" th:href="@{../templates/css/jquery.fancybox.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery.fancybox-buttons.css" th:href="@{../templates/css/jquery.fancybox-buttons.css}"/>
Controller:
@RequestMapping(value="/", method= RequestMethod.GET)
public String contactForm(@Valid @ModelAttribute("contact") Contact contact, BindingResult bindingResult,
HttpServletRequest request, Model model, Device device) throws IOException {
System.out.println("Inside controller-----------------");
main method:
@SpringBootApplication
@ComponentScan(".stidham")
public class StidhamFinancialApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(StidhamFinancialApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(StidhamFinancialApplication.class, args
);
}
}
Only the html renders, no js or css. I have tried several ways and the path I currently have looks correct and even my IDE auto fills as I type in the path.
In the war file they are also in the correct place.
mvn clean install
builds correctly, they're no dependency issues. This seems just like a simple path issue that is not working when deployed.
---------------Update 1---------------
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" type="text/css" href="/css/superfish.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/nivo-slider.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.qtip.min.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox-buttons.css"/>
new paths
Still getting 404 for js and css:
Here is a snippet of the paths I am using:
<link rel="stylesheet" type="text/templates.css" href="../templates/css/superfish.css" th:href="@{../templates/css/superfish.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/style.css" th:href="@{../templates/css/style.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/nivo-slider.css" th:href="@{../templates/css/nivo-slider.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery.qtip.min.css" th:href="@{../templates/css/jquery.qtip.min.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery-ui.css" th:href="@{../templates/css/jquery-ui.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery.fancybox.css" th:href="@{../templates/css/jquery.fancybox.css}"/>
<link rel="stylesheet" type="text/templates.css" href="../templates/css/jquery.fancybox-buttons.css" th:href="@{../templates/css/jquery.fancybox-buttons.css}"/>
Controller:
@RequestMapping(value="/", method= RequestMethod.GET)
public String contactForm(@Valid @ModelAttribute("contact") Contact contact, BindingResult bindingResult,
HttpServletRequest request, Model model, Device device) throws IOException {
System.out.println("Inside controller-----------------");
main method:
@SpringBootApplication
@ComponentScan(".stidham")
public class StidhamFinancialApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(StidhamFinancialApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(StidhamFinancialApplication.class, args
);
}
}
Only the html renders, no js or css. I have tried several ways and the path I currently have looks correct and even my IDE auto fills as I type in the path.
In the war file they are also in the correct place.
mvn clean install
builds correctly, they're no dependency issues. This seems just like a simple path issue that is not working when deployed.
---------------Update 1---------------
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" type="text/css" href="/css/superfish.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/nivo-slider.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.qtip.min.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox-buttons.css"/>
new paths
Still getting 404 for js and css:
Share Improve this question edited Jan 6, 2017 at 23:19 Mike3355 asked Jan 6, 2017 at 12:46 Mike3355Mike3355 12.1k26 gold badges112 silver badges204 bronze badges1 Answer
Reset to default 7The folder "templates" is only reserved for thymeleaf to process html. JavaScript and CSS should be in the folder "static". This folder is mapped directly to the root URL for http.
Example: File located in ... /resources/static/css/superfish.css
<link rel="stylesheet" href="/css/superfish.css" />
本文标签: javascriptCSS and Java Script not rendering 404 error springbootStack Overflow
版权声明:本文标题:javascript - CSS and Java Script not rendering 404 error spring-boot - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744607987a2615475.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论