Struts2中的ActionContext.getContext().getParameters()
Struts2中的action已经脱离的request,是用getXxx()来取提交过来的参数,如果在写程序的时候特定需要自己来取Parameter可以通过以下两种方法实现。第一种用ActionContext类,所有的参数都从这里ActionContext.getContext().getParameters()取他返回的是一个Map类型。
Map param= ActionContext.getContext().getParameters();
若有一个提交过来的username,那么通过param.get("username")可以取值。值得注意的是param.get("username")是一个String数组,Struts就是这样设计的。既然是String数组就需要这样取值:
String value[] = (String[])param.get("username");
String username = "";
for(int i=0;i<value.length;i++)
{
username +=value[i];
}
第二种方法是直接把request引用进来
ServletActionContext.getRequest().getParameter("username")
原帖地址:https://www.jspcn.net/htmlnews/11500549785621702.html
最后更新:2017-04-03 16:49:06
上一篇:
MLBase:Spark生态圈里的分布式机器学习系统
下一篇:
简单操作crud
一个不错的定时程序,写的很好的
为创业公司CEO定制的完美日程表:如何安排你的一天最高产?
Notepad++ 格式化xml
rhel6 ipv6 禁用备忘
如何打造vim风格eclipse界面
tomcat报错INFO: Maximum number of threads (200) created for connector with address null and port 8080
android上拉下拉加载更多数据
《Docker生产环境实践指南》——1.2 从开发环境到生产环境
大中华地区(含港澳台)空气质量接口参加阿里云API as a Service 大赛?
新的开始!