2011-10-27 23 views
3

我們的「/ *」的URL模式和要求得到我們的控制器,但我們總是得到一個404 這裏是我們的web.xml泉和/ * URL模式

<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> 

月-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/*

回答

2

你老兄作爲servlet的名字,但參考BRIO作爲在server.xml中的URL映射servlet名稱

如果這不是問題,你所談論的希望您的應用程序,以迴應http://yourserver/ *而不是http://yourserver/yourcontext/ *,那麼您需要將您的webapp部署爲服務器的根webapp。下面是與該類型的配置在tomcat的問題Tomcat 6: How to change the ROOT application

編輯:從我的意見覆制 - 如果你映射的DispatcherServlet在你的webapp根,你需要在http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler

+0

我提到的默認servlet配置認爲你的誤解,我發現與你的上下文,我想要的是,雖然是在我的web.xml我指 as /和not/spring。 – arinte

+0

好吧,那麼也許看看http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler – digitaljoel