SpringMVC development summary

1. Automatically encapsulate the returned object as JSON

  1). Add the following configuration to the spring configuration file:

    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.json.GsonHttpMessageConverter"/>
        </mvc:message-converters>
    </mvc:annotation-driven>

  2). Add @RestController or @ResponseBody annotation to the method to be converted to the Controller

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324696287&siteId=291194637