struts2.3.15.1 json返字符串格式

使用ssh+ligerUI發現struts2返回json值格式有個奇怪的現象

json類型

<result-types>
	<result-type name="json" class="org.apache.struts2.json.JSONResult" />
</result-types>

<action name="intoListView" class="" method="intoListView">
<span style="white-space:pre">	</span><result name="success" type="json">
	</result>
</action>

前端頁面

var schdJsonArray = '<s:property value="schdJson"  escapeHtml="false" />';
console.log(schdJsonArray);
瀏覽器控制檯輸出格式正確
[{"staffname":"李四"},{"staffname":"張三"}]
</pre><pre code_snippet_id="497916" snippet_file_name="blog_20141027_6_4194355" name="code" class="html">且可以直接轉換成json對象

</pre><pre code_snippet_id="497916" snippet_file_name="blog_20141027_8_9470094" name="code" class="html">var schdJsonArray = '<s:property value="schdJson"  />';
console.log(schdJsonArray);


這樣的話,輸出爲:

[{&quot;staffname&quot;:&quot;李四&quot;},{&quot;staffname&quot;:&quot;張三&quot;}]

不能直接轉換成json對象

但是使用

s:property

取值,頁面上都顯示爲

[{"staffname":"李四"},{"staffname":"張三"}]

不知道爲啥?記錄一下

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章