java - 如何在 Spring 3 中将参数从 View 传递到 Controller

标签 java model-view-controller view jstl spring-3

这是我的 View 片段,单击超链接时我需要发送 Controller 中方法的两个名为 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>

// Controller

@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;
}

提前致谢!

最佳答案

@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;
}

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

关于java - 如何在 Spring 3 中将参数从 View 传递到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10092243/

相关文章:

java - 使用 Java - MongoDB 在服务器上存储函数

java - 在我的应用程序关闭时安排任务

java - SimpleDateFormat.parse()

Azure Web App 文件下载 - 特殊字符问题

asp.net-mvc - ASP.NET MVC 如何应用基于角色或基于身份验证的 View 呈现?

java - 在 Swing 架上执行 Java 应用程序期间出现空白屏幕

iphone - 带有 ARC 的 MVC 模式

javascript - 处理 Bootstrap 表中 URI 的错误

MySQL创建 View 时如何动态选择从哪个表获取数据

android - 如何使状态栏在android中不可触摸?