0

我正在使用 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";  
     } 

但是当

被点击

请帮忙..

4

0 回答 0