网页.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
控制器方法签名:
@RequestMapping(value = {"","/"}, method = RequestMethod.POST)
public ModelAndView index(Model model, @RequestParam("someParam") String someParam)
问题是,当我用尾部斜杠击中根目录时,它工作正常,但是当我在没有尾部斜杠的情况下击中根目录时,JBoss(或浏览器)正在接收请求,并通过带有尾部斜杠的 GET 转发它. 然后我得到以下信息:
HTTP 状态 405 - 不支持请求方法“GET”