解决方案:
Tips: 1. 紫色为原乱码时代码,红色为正确代码
2. 需更改两处文件,缺一不可
struts配置文件:
<result name="reportresult" type="redirectAction">
<param name="actionName">/report/reportresult_queryResult</param>
<param name="querycondition_str">${querycondition_str}</param>
<param name="report_parameter_str">${report_parameter_str}</param>
<param name="report_template_name">${report_template_name}</param>
<param name="encode">true</param>
</result>
重定向后的Action中:
public String queryResult() throws Exception{
//JSONObject query_jsonObj = JSONObject.fromObject(super.getQuerycondition_str());
String str = super.getReport_parameter_str();
if(!(str == null || str.equals(""))){
str=URLDecoder.decode(str, "utf-8");
//str=new String(str.getBytes(),"utf-8");---------原代码
Map<String,Object> parameterMap = new HashMap<String,Object>();
JSONObject obj = JSONObject.fromObject(str);
//json转换成集合对象
MorphDynaBean bean = (MorphDynaBean)JSONObject.toBean(obj);
DynaProperty[] properties = bean.getDynaClass().getDynaProperties();
for(DynaProperty property : properties){
parameterMap.put(property.getName(), obj.get(property.getName()));
}
this.reportService.setParameter(parameterMap);
}
this.reportService.setRequestAndResponse(ServletActionContext.getRequest(), ServletActionContext.getResponse());
this.reportService.setReport(super.getReport_template_name());
this.reportService.viewHtmlReport_itransc();
return null;
}