我正在使用Spring MVC3和Tiles3构建一个Web应用程序..但是我在加载静态资源方面遇到了一些问题。
在 web.xml 中,我有以下代码:
<filter>
<filter-name>static-filter</filter-name>
<filter-class>com.app.common.filter.DefaultFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>static-filter</filter-name>
<url-pattern>/js/*</url-pattern>
<url-pattern>/jsp/*</url-pattern>
<url-pattern>/css/*</url-pattern>
<url-pattern>/images/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>enlightened</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>enlightened</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
DefaultFilter.java 就像:
public class DefaultFilter implements Filter {
private RequestDispatcher defaultRequestDispatcher;
public void destroy() {}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
defaultRequestDispatcher.forward(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
this.defaultRequestDispatcher = filterConfig.getServletContext()
.getNamedDispatcher("default");
}
}
我的文件夹结构就像:
WebContent --
--- css/ all css files
--- js / all js files
--- images / all images
--- jsp /
-- WEB-INF
index.html
首先我正确地获取index.html:通过链接
http://myserver.com:8080/enlightened/index.html
index.html中的我有:
<table>
<tr>
<td><a href="home.html">Sign up!</a></td>
</tr>
</table>
在我的控制器中,我有一个RequestMapping = / home
的方法@RequestMapping("/home")
public String welcome() {
System.out.println("/home.htm");
return "welcome";
}
但
时我的控制器中没有流量单击
请帮助..