近来要Struts 爆出漏洞,需要升级,把原来 2.1.8升级2.3.15.1 ,版本升级比较大,出现了一些问题。
由于Action里继承ModelDriven, 出现了返回JSON为空的问题
Action的代码:
public class ResourcesAction implements ModelDriven<ResourcesVo>{
private ResourcesVo resources =new ResourcesVo();
private List<ResourcesVo> resourcesList;
@Override
public ResourcesVo getModel() {
// TODO Auto-generated method stub
return resources;
}
/**
* 查询List
* @return
*/
public String queryResourcesList() {
try {
resourcesList = resourcesInfoApplication.queryRescourcesList(resources);
} catch (Exception e) {
e.printStackTrace();
}
return "JSON";
}
.....
}
struts.xml
原来
<action name="queryResourcesPageList" class="com.csair.gme.web.action.core.ResourcesAction"
method="queryResourcesPageList">
<result name="JSON" type="json">
<param name="excludeProperties">.*Application$</param>
<param name="includeProperties"></param>
<param name="excludeNullProperties">true</param>
<param name="ignoreHierarchy">false</param>
</result>
<result name="ERROR_REDIRECT" type="redirect">/common/error.jsp</result>
</action>
添加一行<param name="root">action</param>
修改为:
<action name="queryResourcesPageList" class="com.csair.gme.web.action.core.ResourcesAction"
method="queryResourcesPageList">
<result name="JSON" type="json">
<param name="excludeProperties">.*Application$</param>
<param name="includeProperties"></param>
<param name="excludeNullProperties">true</param>
<param name="ignoreHierarchy">false</param>
<param name="root">action</param>
</result>
<result name="ERROR_REDIRECT" type="redirect">/common/error.jsp</result>
</action>
问题解决。
这个版本修改比较大,还存在其他的一些问题需要修改。。