1.spring过滤的url-pattern设置成了/,所以这里随便给个新的后缀
<welcome-file-list>
<welcome-file>index.zl</welcome-file>
</welcome-file-list>
2.新增一个过滤/index.zl
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/index.zl</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
3.controller
@Controller
@Scope("prototype")
@RequestMapping("/index.zl")
public class IndexController { @Autowired
IndexService indexService; @RequestMapping()
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView mv=new ModelAndView();
return mv;
} }