我有一个部署在上面的 webapp(基于 Spring MVC)/mobile
(详情如下)。问题是:
当我去http://localhost:8080/mobile/
orhttp://localhost:8080/mobile/index
时,一切正常。
但是当我去http://localhost:8080/mobile
(注意最后缺少的斜线)时,我得到一个 404 错误。为什么会这样(以及如何修复它)?
网页.xml:
<servlet>
<servlet-name>mobileServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/mobile-servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mobileServlet</servlet-name>
<url-pattern>/mobile/*</url-pattern>
</servlet-mapping>
控制器:
@Controller
public class MobileAppController {
@RequestMapping({"", "/", "/index"})
public String index() {
return "/mobile/index";
}
}