REST API plugin - use body instead of query string for parameters

后端 未结 1 1337
感动是毒
感动是毒 2020-12-04 00:10

I\'m using this as a reference to create a REST only configuration on Struts2:

https://cwiki.apache.org/confluence/display/WW/REST+Plugin

I have one model, R

相关标签:
1条回答
  • 2020-12-04 01:05

    I guess that postman is sending JSON in the body of the request and sets the content type application/json. Struts can parse the request if you add json interceptor to the stack.

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

    The description for "json" interceptor in the JSON Plugin:

    If the interceptor is used, the action will be populated from the JSON content in the request, these are the rules of the interceptor:

    • The "content-type" must be "application/json"
    • The JSON content must be well formed, see json.org for grammar.
    • Action must have a public "setter" method for fields that must be populated.
    • Supported types for population are: Primitives (int,long...String), Date, List, Map, Primitive Arrays, Other class (more on this later), and Array of Other class.
    • Any object in JSON, that is to be populated inside a list, or a map, will be of type Map (mapping from properties to values), any whole number will be of type Long, any decimal number will be of type Double, and any array of type List.

    Resources:

    • FAQ
    • Getting started
    • The resources page
    0 讨论(0)
提交回复
热议问题