[英]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.