Im trying to get JSON data from js and receiving null in action class

China☆狼群 提交于 2019-12-06 04:21:42

If you need to produce JSON (Action -> JSP), the json result is enough.

If you need to consume JSON (JSP -> Action), you need to add the Json Interceptor to your stack.

From the documentation:

Accepting JSON

Your actions can accept incoming JSON if they are in package which uses json interceptor or by adding reference to it as follow:

@InterceptorRef(value="json")

Also note that the json-default package internally extends the struts-default, hence there is no need to extend both of them.

It should be:

<package name="default" namespace="/" extends="json-default">

    <interceptor-stack name="jsonFromJspStack">
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="json" />
    </interceptor-stack>


    <action name="retrieve-seat" class="com.pointwest.apex.actions.ReadPositionAction">
        <interceptor-ref name="jsonFromJspStack"/>
        <result name="SUCCESS" type="json"/>
    </action>

</package>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!