@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
其实问题不在这里,我在form中的action路径写错了,问题解决了
谢谢你!