歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Struts 轉化Json時候出現出現無法轉化

Struts 轉化Json時候出現出現無法轉化

日期:2017/3/1 10:22:49   编辑:Linux編程

在處理action 返回json數據時候出現:

Class org.apache.struts2.json.JSONWritercan not access a member of class Oracle.jdbc.driver.BaseResultSet withmodifiers "public"

該問題的產生是由於某些對象json無法轉化導致;

處理:在struts 中配置:

eg:

<package name="loginJson"extends="json-default" >

<action name="rolejson_*"class="roleAction" method="{1}">

<result name="rolePage"type="json">/WEB-INF/pages/system/roleManagePage.jsp

<paramname="excludeProperties">page\.list\[\d+\]\.prSUSEr,page\.list\[\d+\]\.setPri,roleService</param>

</result>

</action>

</package>

其中的參數:<param name=”excludeProperties”> 可以排除你不需要的屬性

注意凡是在在action 中有get()方法的json均會默認去轉化它。。當然這也包括你配置的service 屬性,本次出現的問題就是在service上。。排除後就不再出現問題;你也可以使用 name=”includeProperties” 添加你想要轉化的屬性;

這個類似與spring作為分發頁面功能時候使用的:

JsonConfigjsonConfig = new JsonConfig();

jsonConfig.setExcludes(String[]excludes);

Copyright © Linux教程網 All Rights Reserved