標籤:httprequest
前台頁面帶著areaid參數請求更新此id的資料,跳轉到更新資料頁面時需要在更新頁面先填充上原來的資料。用request.setAttribute和request.getAttribute的搭配使用來解決此問題。
</pre><pre name="code" class="plain">
@RequestMapping(value="area_updateInput.action")public String areaUpdateInput(int areaId,HttpServletRequest request){System.out.println(areaId);List<AreaDomain> area=areaService.getAreaById(areaId);<strong><span style="color:#ff0000;">request.setAttribute("areaname", area.get(0).getAreaName());</span></strong>request.setAttribute("areamap", area.get(0).getAreaMap());request.setAttribute("arearemark", area.get(0).getAreaRemark());request.setAttribute("areaextend", area.get(0).getAreaExtend());request.setAttribute("areascales", area.get(0).getAreaScales());request.setAttribute("devicetablename", area.get(0).getDeviceTablename());request.setAttribute("spacetablename", area.get(0).getSpaceTablename());request.setAttribute("pathtablename", area.get(0).getPathTablename());return "person_manage/area/area_update_input";}
var devInfoForm = new Ext.FormPanel({ labelWidth: 75, // label settings here cascade unless overridden frame:true, title: '更新地區', bodyStyle:'padding:5px 5px 0', width: 350, defaults: {width: 230}, defaultType: 'textfield',name:"areaInfo", items: [{ fieldLabel: '地區名稱', name: 'areaName', <strong><span style="color:#ff0000;">value:'<%=request.getAttribute("areaname")%>',</span></strong> allowBlank : false //此驗證依然有效.不許為空白. },{ fieldLabel: '地區地圖', name: 'areaMap', value:'<%=request.getAttribute("areamap")%>'},{ fieldLabel: '地區備忘', name: 'areaRemark', value:'<%=request.getAttribute("arearemark")%>'},{ fieldLabel: '地區座標', name: 'areaExtend', value:'<%=request.getAttribute("areaextend")%>', regex :/^[+-]?([1-9][0-9]*|0),[+-]?([1-9][0-9]*|0),[+-]?([1-9][0-9]*|0),[+-]?([1-9][0-9]*|0)$/, //Regex在/...../之間. regexText:"格式例如10,-60,80,0", allowBlank : false //此驗證依然有效.不許為空白. },{ fieldLabel: '地區比例', name: 'areaScales', value:'<%=request.getAttribute("areascales")%>', regex : /^([1-9][0-9]*|0),([1-9][0-9]*|0),([1-9][0-9]*|0)$/, regexText:"格式例如400000,250000,80000", allowBlank : false },{ fieldLabel: '裝置表名', name: 'deviceTablename', value:'<%=request.getAttribute("devicetablename")%>'},{ fieldLabel: '空間表名', name: 'spaceTablename', value:'<%=request.getAttribute("spacetablename")%>'},{ fieldLabel: '路徑表名', name: 'pathTablename', value:'<%=request.getAttribute("pathtablename")%>'} ],
request.setAttribute和request.getAttribute的搭配使用