我们有一个“/*”的 url 模式并且请求到达我们的控制器,但我们总是得到 404。
这是我们的 web.xml
<servlet>
<servlet-name>bro</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:mo/config/mo-spring.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>bro</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
mo-spring.xml:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="suffix" value=".jsp"/>
</bean>
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/views/" location="/views/" />
控制器的一点:
@RequestMapping(value="/signon", method=RequestMethod.GET)
public String signon(HttpServletRequest request) {
...
return "/WEB-INF/index";
}
如果我在 web.xml 中使用 /xxx/* 作为 url-pattern,一切都会按预期工作,但是我们有一个 dojo 应用程序,我们真的不想修改它想要与 /* 而不是 /xxx/* 对话
您将 bro 作为 servlet 名称,但在 server.xml 中引用 brio 作为 url 映射的 servlet 名称
如果这不是问题并且您正在谈论希望您的应用程序响应http://你的服务器/ http://yourserver/* 代替http://你的服务器/你的上下文/ http://yourserver/yourcontext/* 然后您需要将您的 Web 应用程序部署为服务器的根 Web 应用程序。这是一个与tomcat中的此类配置相关的问题Tomcat 6:如何更改ROOT应用程序 https://stackoverflow.com/questions/715506/tomcat-6-how-to-change-the-root-application
edit:复制自我的评论 - 如果您将 DispatcherServlet 映射到 web 应用程序中的根目录,您将需要中提到的默认 servlet 配置http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)