Tôi muốn sử dụng json với Struts2. Tuy nhiên, khi tôi đặt kiểu trả về hành động là "json", tôi nhận được "không có loại kết quả nào được định nghĩa cho loại 'json' được ánh xạ với tên 'thành công'." Dưới đây là tệp struts.xml.không thể đặt loại kết quả Struts2 thành json
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.custom.i18n.resources" value="resource"/>
<package extends="struts-default" name="test">
<action name="inputHandler" class="inputHandlerAction">
<result name="input">/index.jsp</result>
<result>/result.jsp</result>
</action>
<action name="setLangHandler" class="com.sesoft.test.setLanguageHandler">
<result>/index.jsp</result>
</action>
<action name="Handler" class="com.sesoft.test.Handler">
<result>/test2.jsp</result>
</action>
</package>
<package name="example" extends="json-default">
<action name="ajaxHandler" class="com.sesoft.test.AjaxHandler">
<result name="success" type="json" />
</action>
</package>
</struts>
Trước khi tôi thêm hành động json, mọi hành động khác đều hoạt động tốt. Nhưng sau khi tôi thêm hành động json, máy chủ không hoạt động với mã lỗi 503.
libs Tôi đã thêm "jsonplugin-0.33.jar" vào thư mục lib.
Dường như Plugin Google cho json đã được thay thế bằng Plugin Juts Struts2: https://cwiki.apache.org/S2PLUGINS/json-plugin.html 'Plugin JSON được đóng gói với Struts kể từ 2.1.7+. Plugin tại Google Code đã không được chấp nhận.' –