0

在我的控制器中:

@Controller
@RequestMapping(value="Main")
/*the methods */
 @RequestMapping(value="/index.do", method = RequestMethod.GET)

在我的 web.xml 中:

   <servlet-mapping>
      <servlet-name>MyController</servlet-name>
      <url-pattern>*.do</url-pattern>
   </servlet-mapping>
   <welcome-file-list>  
        <welcome-file>Main/index.do</welcome-file>  
    </welcome-file-list>

当我输入 :localhost/projectname/时,它不会localhost/projectname/Main/index.do像我预期的那样导致,并且在 Eclipse 的控制台中没有任何输出。

但是如果我尝试整个 URL localhost/projectname/Main/index.do,控制器就会响应我想要的。

那么我应该如何配置我的欢迎文件列表呢?

4

1 回答 1

0

实际文件<welcome-file-list>组成,而不是 URL。所以你不能放进去。您可以做的是放置一个简单的 html 文件,该文件会重定向到以下内容:Main/index.doindex.do

<html xmlns="http://www.w3.org/1999/xhtml">    
  <head>      
    <meta http-equiv="refresh" content="0;URL='/Main/index.do'" />    
  </head>    
  <body> 
    <p><a href="/Main/index.do">Main page</a>.</p> 
  </body>  
</html> 

永远不应该评估 body 块。

于 2014-05-28T16:27:36.327 回答