[英]How to pass parameters from cordova HTTP to Spring controller
[英]how to pass parameters from view to controller in Spring 3
这是我的视图片段,单击超链接时,我需要将名为 solicitudId 和 detailId 的两个参数发送到 controller 中的方法
<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>
//控制器
@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
您需要一个 controller 方法来接受 HTTP 请求 object。参数将作为名称/值对作为 GET 请求的一部分。 像这样:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.