I created a mapping in web.xml something like this:
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/about/*</url-pattern>
</servlet-mapping>
In my controller, I have something like this:
import org.springframework.stereotype.Controller;
@Controller
public class MyController{
@RequestMapping(value="/about/us", method=RequestMethod.GET)
public ModelAndView myMethod1(ModelMap model){
return new ModelAndView("aboutus1.jsp",model);
}
@RequestMapping(value="/about", method=RequestMethod.GET)
public ModelAndView myMethod2(ModelMap model){
return new ModelAndView("aboutus2.jsp",model);
}
}
And my dispatcher-servlet.xml looks like a resolving kind, for example:
<mvc:annotation-driven/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"/>
To my surprise, the request .../about/usdoes not reach myMethod1 in the controller. Error 404 is displayed in the browser. I place the logger inside the method, but it does not print anything, which means that it does not execute.
.../aboutworks great! What can be done to make the request .../about/uswork? Any suggestions?
source
share