Struts 2操作不使用json数据

时间:2019-06-11 18:48:49

标签: json web-services struts2

我已经配置了Struts 2 Action的简单Web服务调用并对其进行了编码。我没有从调用中获取数据,但它正确返回了JSON。我正在用邮递员打来电话。

public class WSLaborJONAction
{
    // this property is not getting populated on the call
    private String test;

    public String execute() throws Exception
    {
         ...some code
         return "success";
    }

    public String getTest()
    {
            return test;
    }

    public void setTest(String test)
    {
        this.test = test;
    }
}

<package name="webservices" namespace="/" extends="json-default">
    <result-types>
        <result-type name="json" class="org.apache.struts2.json.JSONResult" />
    </result-types>
    <interceptors>
        <interceptor name="json" class="org.apache.struts2.json.JSONInterceptor" />
    </interceptors>

    <!-- LABOR JON -->  
    <action name="WSLaborJON" class="mil.ndms.taa.af.webservices.labor.WSLaborJONAction">
        <result name="success" type="json" />
    </action>       

</package>

GET /taa/WSLaborJON
Content-Type: application/json
User-Agent: PostmanRuntime/7.13.0
Accept: '*/*'
Cache-Control: no-cache
Postman-Token: 111a91a2-919f-4469-a96c-c5b666c9ebec
Host: localhost:8080
accept-encoding: gzip, deflate
content-length: 30
Connection: keep-alive
{
    "test":"MyInputTest"
}

HTTP/1.1 200
status: 200
Server: Apache-Coyote/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 23
Date: Tue, 11 Jun 2019 18:02:13 GMT
{"test":"MyOutputTest"}

我的String测试始终为null。我需要在JSON调用的Action中使用它。对我想念的东西有什么想法吗?

0 个答案:

没有答案