Tôi đã tạo ứng dụng MVC.Spring MVC - bao gồm các tệp tĩnh/javascript, css
Tôi muốn đưa tệp js hoặc css vào jsp.
file tĩnh của tôi ar dưới:
- webapp -js/jquery.js -WEB-INF| | - jsp/*.jsp
Mã của tôi bao gồm jquery là:
<script type="text/javascript" src="<c:url value="js/jquery.js" />"></script>
và tôi không thể tải các js nộp vào xem.
tôi thấy các bản ghi với thông tin:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/pool/js/jquery.js] in DispatcherServlet with name 'appServlet'
những gì có nghĩa, rằng MVC thử để lập bản đồ url đến file js.
Tôi nghĩ rằng có gì đó với cấu hình của tôi, nhưng tôi không biết gì.
web.xml của tôi là:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Xem: http://stackoverflow.com/questions/10495571/spring-not-finding-resource-files-css-jsp – ALOToverflow