request.setAttribute和request.getAttribute的搭配使用

來源:互聯網
上載者:User

標籤: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的搭配使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.