@RestController

package org.springframework.web.bind.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Controller;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Controller
@ResponseBody
public @interface RestController {
    @AliasFor(
        annotation = Controller.class
    )
    String value() default "";
}

其中一个注解是Controller 标明是一个控制器,另一个注解@ResponseBody,标明要返回的数据是JSON数据。所以最后的效果就是在网页返回JSON数据

原文地址:https://www.cnblogs.com/10134dz/p/13776510.html