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
展开
 我来答
百度网友8a627e7
2014-05-22 · TA获得超过304个赞
知道小有建树答主
回答量:705
采纳率:50%
帮助的人:456万
展开全部
去掉@RequestParam注解,这两个是这样用的

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

这样才加@RequestParam注解 
追问
其实问题不在这里,我在form中的action路径写错了,问题解决了
谢谢你!
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式