标签: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)$/, //正则表达式在/...../之间. 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的搭配使用
标签:httprequest
原文地址:http://blog.csdn.net/zhangxbj/article/details/44308525