如何在Spring 3中将参数从视图传递到控制器

Luc*_*cas 3 java model-view-controller jstl view spring-3

这是我视图的一个片段,当点击超链接时,我需要将两个名为solicitudId和detailId的参数发送到控制器中的方法

<tr>
    <td>${user.loginName}</td>
    <td>${user.phone}</td>
    <td>${user.address}</td>
    <td><a href="/enable?solicitudId=${user.solicitudId}&detailId=${user.detail}">Enable</a></td>
tr>
Run Code Online (Sandbox Code Playgroud)

//控制器

@RequestMapping(value="/enable", method=RequestMethod.GET)
    public String enableUser(Model model){
        try{
            //How should I get the values from the parameters solicitudId and detailId?
        }catch(Exception e){
            e.printStackTrace();
        }
        return  null;
}
Run Code Online (Sandbox Code Playgroud)

提前致谢!

Arn*_*lay 5

@RequestMapping(value="/enable", method=RequestMethod.GET)
    public String enableUser( @RequestParam("solicitudId") int solicitudId ,   
                              @RequestParam("detailId") int detailId, Model model){
        try{
            //do whatever you want with detailId and solicitudId
        }catch(Exception e){
            e.printStackTrace();
        }
        return  null;
}
Run Code Online (Sandbox Code Playgroud)

参考:http: //static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch16s11.html