码迷,mamicode.com
首页 > 其他好文 > 详细

@RestController

时间:2020-10-07 21:05:52      阅读:22      评论:0      收藏:0      [点我收藏+]

标签:注解   pac   bin   控制器   time   body   core   package   string   

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数据
技术图片

@RestController

标签:注解   pac   bin   控制器   time   body   core   package   string   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!