3

We have a url-pattern of "/*" and requests get to our controller, but we always get a 404. Here is our 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/" />

A bit of the controller:

@RequestMapping(value="/signon", method=RequestMethod.GET)
public String signon(HttpServletRequest request) {
            ...
    return "/WEB-INF/index";
}

If i use /xxx/* as the url-pattern in my web.xml everything works as expected, but we have a dojo app that we really don't want to modify that wants to talk to /* and not /xxx/*

arinte
  • 3,660
  • 10
  • 45
  • 65

1 Answers1

2

You have bro as the servlet name, but reference brio as the servlet name for your url mapping in server.xml

If that's not the problem and you are talking about wanting your app to respond to http://yourserver/* instead of http://yourserver/yourcontext/* then you need to deploy your webapp as the root webapp for the server. Here's a question relating to that kind of configuration in tomcat Tomcat 6: How to change the ROOT application

edit: copied from my comment - If you are mapping DispatcherServlet to root in your webapp you will need the default-servlet configuration mentioned in http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler

Community
  • 1
  • 1
digitaljoel
  • 26,265
  • 15
  • 89
  • 115
  • I think you misunderstand, I am find with the yourcontext, what I want though is that in my web.xml I refer to as / and not /spring. – arinte Oct 27 '11 at 18:08
  • alright, then perhaps have a look at http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler – digitaljoel Oct 27 '11 at 18:15