spring mvc使用了 @RequestMapping注解后,在jsp页面的form的action属性的url怎么写?
@Controller@RequestMapping("/user")publicclassUserController{@ResourceprivateUserServ...
@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 展开
@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 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询