使用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);
这样的话,输出为:
[{"staffname":"李四"},{"staffname":"张三"}]
不能直接转换成json对象
但是使用
s:property
取值,页面上都显示为
[{"staffname":"李四"},{"staffname":"张三"}]