我已經創建了MVC應用程序。Spring MVC - 包含靜態文件/ javascript,css
我想將js或css文件包含到jsp中。
我的靜態文件下AR:
- webapp -js/jquery.js -WEB-INF| | - jsp/*.jsp
我的代碼,包括jQuery是:
<script type="text/javascript" src="<c:url value="js/jquery.js" />"></script>
,我不能加載JS文件進入視野。
我看到日誌與信息:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/pool/js/jquery.js] in DispatcherServlet with name 'appServlet'
是什麼意思,是MVC嘗試URL映射到js文件。
我認爲有一些與我的配置,但我不知道是什麼。
我的web.xml是:
<?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>
參見:http://stackoverflow.com/questions/10495571/spring-not-finding-resource-files-css-jsp – ALOToverflow 2013-10-17 17:08:42