Stutus2 从request 作用域 抓取数据到后台ACTION

 
/**
	 * 将request中用户的查询参数传   这里抓取的是 key值以“dfs_”开头的变量
	 * @param request
	 * @return
	 */
	private Map processParamMap(HttpServletRequest request) {
		Map<String,Object> bussinessDataMap = new HashMap<String,Object>();
		Map<String,Object> requestData = ActionContext.getContext().getParameters();
		Iterator<Entry<String,Object>> it = requestData.entrySet().iterator();
		while(it.hasNext()){
			Entry pairs = (Entry)it.next();
			String key = (String)pairs.getKey();
			String value= PersistentsUtil.getString(pairs.getValue(), "");
			if(key.startsWith("dfs_")){
				bussinessDataMap.put(key, value.trim());
			}
		}
		
		return bussinessDataMap;
		
	}
 
//此为 转换json 为 googleCode方式
//需要导入的包
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
 
//代码片段  --功能 将json字符串 转化为 List 然后再根据KEY提取值   -方法Gson.fromJson(jsonStr, classOfT);  
 
Type type = new TypeToken<List<Map<String, String>>>() {}.getType();
    List<Map<String, String>> tempLst = (List<Map<String, String>>)  Gson.fromJson(df_detailsjosn, type);
    
    for (Map<String, String> detailsmap : tempLst) {
     UploadCarpicChangeDetails uploadCarpicChangeDetails = new UploadCarpicChangeDetails();
     uploadCarpicChangeDetails.setCarpicId(Long.valueOf( detailsmap.get("carpicid").trim().replace(" ", "") ));
     uploadCarpicChangeDetails.setCarpicName(detailsmap.get("carpicname").trim().replace(" ", ""));
     uploadCarpicChangeDetails.setCarpicNumber(detailsmap.get("carpicnumber").trim().replace(" ", ""));
     uploadCarpicChangeDetails.setCarpicVersion(detailsmap.get("carpicversion").trim().replace(" ", ""));    
     listcarpicchangedetails.add(uploadCarpicChangeDetails);
   }
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值