spring mvc使用了 @RequestMapping注解后,在jsp页面的form的action属性的url怎么写?

@Controller
@RequestMapping("/user")
public class UserController{

@Resource
private UserService userService;
@RequestMapping(value="/login.do",method=RequestMethod.POST)
public String login(@RequestParam String name,@RequestParam String password,Model model,HttpServletRequest request,HttpServletResponse response)throws Exception{
System.out.println(name+","+password);
if(name.equals("")&&password.equals("")){
return null;
}
}
<div>
<form action="user/login.do" method="post">
<input name="name" type="text"/>
<input name="password" type="password"/>
</form>
<div/>
在这个表单的action的url怎么填,我写的都报错了:
Resolving exception from handler [public java.lang.String com.controller.UserController.login(java.lang.String,java.lang.String,org.springframework.ui.Model,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception]: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'name' is not present

第1个回答  2014-05-22
去掉@RequestParam注解,这两个是这样用的

@RequestMapping(value="/login.do/{name}/{password}",method=RequestMethod.POST)

这样才加@RequestParam注解 追问

其实问题不在这里,我在form中的action路径写错了,问题解决了
谢谢你!

本回答被提问者采纳
相似回答