假设页面提交表单的地址为一个Action:Update.do?id="..."
后台Struts 2获取参数方式
Map map=ActionContext.getContext().getParameters();
String[] temp=(String [])map.get("id");//map.get("id")得到的是Object[],要转成String[]
String id=temp[0];//其实只有一个。。。
本文介绍了一种通过Struts2框架获取表单提交参数的方法。具体步骤为使用ActionContext获取上下文参数,再将获取到的对象数组转换为字符串数组以读取参数值。
假设页面提交表单的地址为一个Action:Update.do?id="..."
后台Struts 2获取参数方式
Map map=ActionContext.getContext().getParameters();
String[] temp=(String [])map.get("id");//map.get("id")得到的是Object[],要转成String[]
String id=temp[0];//其实只有一个。。。

被折叠的 条评论
为什么被折叠?