I would like to have my Spring MVC application mapped to the following extension *html for jsp and *.action for controllers.
this is for login page:
@RequestMapping(value="/login.html", method=RequestMethod.GET)
public ModelAndView login(){
    ModelAndView mv = new ModelAndView("login/开发者_如何学JAVAlogin");
    //omitted
    return mv;
}
and this is for action:
@RequestMapping(value="/login.action", method=RequestMethod.POST)
    public ModelAndView actionSignUp(@Valid User user){ 
    //omitted
    return mv;
    }
and jsp is simple:
<form:form  method="POST" action="/login.action" commandName="user" >
<form:input path="userName" id="userName" /><br />
<form:input path="password" id="password"/><br />
 <input id ="login" type="submit" value="Login"></input>
</form:form>
my web.xml is the following:
 <display-name>SpringMVC</display-name>
    <servlet>
    <servlet-name>springMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springMVC</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
   <servlet-mapping>
    <servlet-name>springMVC</servlet-name>
    <url-pattern>*.action</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
   <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
I have no problem to get /login.html, but I have a problem with POST request on /login.action
I'm getting
HTTP Status 404 - /login.action
Why my mapping for *.action is not working?
Can I map two different extensions *html and *.action ?
The action method in your form was defined as action="/login.action". The / makes the url relative to your domain. You should notice that the form posted to a url similar to http://localhost:8080/login.action which should be http://localhost:8080/[context root]/[sub dir if defined]/login.action
I recon that removing the '/' will fix it.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论