当前位置: 首页>>代码示例>>Java>>正文


Java RestController类代码示例

本文整理汇总了Java中org.springframework.web.bind.annotation.RestController的典型用法代码示例。如果您正苦于以下问题:Java RestController类的具体用法?Java RestController怎么用?Java RestController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RestController类属于org.springframework.web.bind.annotation包,在下文中一共展示了RestController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAsyncRequest

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
/**
 * 判断请求是否是异步请求
 * @param request
 * @param handler
 * @return
 */
public static boolean isAsyncRequest(HttpServletRequest request, Object handler){
	boolean isAsync = false;
	if(handler instanceof HandlerMethod){
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		isAsync = handlerMethod.hasMethodAnnotation(ResponseBody.class);
		if(!isAsync){
			Class<?> controllerClass = handlerMethod.getBeanType();
			isAsync = controllerClass.isAnnotationPresent(ResponseBody.class) || controllerClass.isAnnotationPresent(RestController.class);
		}
		if(!isAsync){
			isAsync = ResponseEntity.class.equals(handlerMethod.getMethod().getReturnType());
		}
	}
	if(!isAsync){
		isAsync = HttpUtils.isAsynRequest(request);
	}
	return isAsync;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:25,代码来源:SpringMvcUtils.java

示例2: petApi

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Bean
public Docket petApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(withClassAnnotation(RestController.class))
            .build()
            .pathMapping("/")
            .enableUrlTemplating(true)
            .apiInfo(apiInfo())
            .ignoredParameterTypes(
                    HttpServletRequest.class,
                    HttpServletResponse.class,
                    HttpSession.class,
                    Pageable.class,
                    Errors.class
            );
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:18,代码来源:SwaggerConfig.java

示例3: process

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

    Set<? extends Element> elementsAnnotatedWithRestController = roundEnv.getElementsAnnotatedWith(RestController.class);
    for (Element restControllerAnnotatedElement: elementsAnnotatedWithRestController) {

        if (restControllerAnnotatedElement.getKind() != ElementKind.CLASS) {
            error(restControllerAnnotatedElement, "@%s can be applied only to class",
                    RestController.class.getSimpleName());
            return true;
        }
        if (Objects.isNull(restControllerAnnotatedElement.getAnnotation(RequestMapping.class))) {
            warn(restControllerAnnotatedElement, "%s without @RequestMapping will not produce any @Test methods.",
                    restControllerAnnotatedElement.getSimpleName().toString());
        }
        // @RequestMapping 붙은 클래스
        TypeElement restControllerTypeElement = (TypeElement) restControllerAnnotatedElement;

        // 분석용 래퍼 클래스
        RestControllerModel restControllerModel = new RestControllerModel(restControllerTypeElement);
        generateStubFileFor(restControllerModel);
    }

    return false;
}
 
开发者ID:HomoEfficio,项目名称:spring-web-api-test-stubber,代码行数:26,代码来源:RestControllerProcessor.java

示例4: getSpringClassAnnotation

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
private Annotation getSpringClassAnnotation(Class clazz) {
    Annotation classAnnotation = AnnotationUtils.findAnnotation(clazz, Component.class);

    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Controller.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, RestController.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Service.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Repository.class);
    }

    return classAnnotation;
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:19,代码来源:SpringReloader.java

示例5: api

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
            // .paths(paths())
            .build().pathMapping("/").directModelSubstitute(LocalDate.class, String.class)
            .genericModelSubstitutes(ResponseEntity.class).useDefaultResponseMessages(false)
            .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message")
                    .responseModel(new ModelRef("Error")).build()));
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:10,代码来源:SwaggerConfig.java

示例6: api

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
            .groupName("api")
            .select()
            .apis(withClassAnnotation(RestController.class))
            .paths(PathSelectors.regex("/api/.+"))
            .build()
            .apiInfo(apiInfo());
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:11,代码来源:SwaggerConfiguration.java

示例7: internal

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Bean
public Docket internal() {
    return new Docket(DocumentationType.SWAGGER_2)
            .groupName("internal")
            .select()
            .apis(withClassAnnotation(RestController.class))
            .paths(PathSelectors.regex("/internal/.+"))
            .build()
            .apiInfo(apiInfo());
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:11,代码来源:SwaggerConfiguration.java

示例8: init

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
private void init(ApplicationContext context) {
	init();
	LOGGER.debug("Get All ExceptionHandlers");
	List<Object> exceptionsHandlers = ReflectionUtils
			.proxyToObject(context.getBeansWithAnnotation(ControllerAdvice.class).values());
	LOGGER.debug("Get All RestController");
	exceptionsHandlers.forEach(this::buildHttpCodes);
	controllers
			.addAll(ReflectionUtils.proxyToObject(context.getBeansWithAnnotation(RestController.class).values()));
	LOGGER.debug("Get All Controller");
	controllers.addAll(ReflectionUtils.proxyToObject(context.getBeansWithAnnotation(Controller.class).values()));
}
 
开发者ID:damianwajser,项目名称:spring-rest-commons-options,代码行数:13,代码来源:ResourcesBuilder.java

示例9: isAjax

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
/**
 * 判断是否ajax请求
 * spring ajax 返回含有 ResponseBody 或者 RestController注解
 * @param handlerMethod HandlerMethod
 * @return 是否ajax请求
 */
public static boolean isAjax(HandlerMethod handlerMethod) {
	ResponseBody responseBody = handlerMethod.getMethodAnnotation(ResponseBody.class);
	if (null != responseBody) {
		return true;
	}
	RestController restAnnotation = handlerMethod.getBeanType().getAnnotation(RestController.class);
	if (null != restAnnotation) {
		return true;
	}
	return false;
}
 
开发者ID:TomChen001,项目名称:xmanager,代码行数:18,代码来源:WebUtils.java

示例10: isJson

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
/**
 * 判断整个类里的所有接口是否都返回json
 *
 * @param classz
 * @return
 */
protected boolean isJson(Class<?> classz) {
    Controller controllerAnno = classz.getAnnotation(Controller.class);
    RestController restControllerAnno = classz.getAnnotation(RestController.class);
    ResponseBody responseBody = classz.getAnnotation(ResponseBody.class);

    if (responseBody != null) {
        return true;
    } else if (controllerAnno != null) {
        return false;
    } else if (restControllerAnno != null) {
        return true;
    }
    return false;
}
 
开发者ID:treeleafj,项目名称:xDoc,代码行数:21,代码来源:SpringXDocOutputImpl.java

示例11: filter

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Override
public boolean filter(Class<?> classz) {
    if (classz.getAnnotation(RequestMapping.class) != null
            || classz.getAnnotation(Controller.class) != null
            || classz.getAnnotation(RestController.class) != null) {
        return true;
    }
    return false;
}
 
开发者ID:treeleafj,项目名称:xDoc,代码行数:10,代码来源:SpringClassFilter.java

示例12: matches

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Override
public boolean matches(Method method, Class<?> aClass) {
    boolean support = AopUtils.findAnnotation(aClass, Controller.class) != null
            || AopUtils.findAnnotation(aClass, RestController.class) != null
            || AopUtils.findAnnotation(aClass, method, Authorize.class) != null;

    if (support && autoParse) {
        defaultParser.parse(aClass, method);
    }
    return support;
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:12,代码来源:AopAuthorizingController.java

示例13: api

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Bean
public Docket api() {

    return new Docket(DocumentationType.SWAGGER_2)
            .groupName("default")
            .select()
            .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
            .paths(PathSelectors.any())
            .build()
            .protocols(Sets.newHashSet(getSwaggerConfig().getString(SWAGGER_PROTOCOL)))
            .apiInfo(apiInfo())
            .securitySchemes(newArrayList(securitySchema()))
            .securityContexts(newArrayList(securityContext()))
            // .operationOrdering(getOperationOrdering()) try with swagger 2.7.0
            .tags(
                    new Tag("alert triggers", "Operations to manage alert triggers"),
                    new Tag("applications", "Operations to list organization applications"),
                    new Tag("application document store", "Operations to manage generic documents storage"),
                    new Tag("device configs", "Operations to manage device configurations"),
                    new Tag("device credentials", "Operations to manage device credentials (username, password and URLs)"),
                    new Tag("device firmwares", "Operations to manage device firmwares"),
                    new Tag("device models", "Operations to manage device models"),
                    new Tag("device status", "Operations to verify the device status"),
                    new Tag("devices", "Operations to manage devices"),
                    new Tag("devices custom data", "Operations to manage devices custom data"),
                    new Tag("events", "Operations to query incoming and outgoing device events"),
                    new Tag("gateways", "Operations to manage gateways"),
                    new Tag("locations", "Operations to manage locations"),
                    new Tag("rest destinations", "Operations to list organization REST destinations"),
                    new Tag("rest transformations", "Operations to manage REST transformations"),
                    new Tag("routes", "Operations to manage routes"),
                    new Tag("users", "Operations to manage organization users"),
                    new Tag("user subscription", "Operations to subscribe new users")

                 )
            .enableUrlTemplating(false);

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:39,代码来源:SwaggerUIConfig.java

示例14: getSupportedAnnotationTypes

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Override
public Set<String> getSupportedAnnotationTypes() {

    Set<String> annotataions = new LinkedHashSet<String>();
    annotataions.add(org.springframework.web.bind.annotation.RestController.class.getCanonicalName());
    return annotataions;
}
 
开发者ID:HomoEfficio,项目名称:spring-web-api-test-stubber,代码行数:8,代码来源:RestControllerProcessor.java

示例15: postProcessBeanFactory

import org.springframework.web.bind.annotation.RestController; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
	
	Map<RequestMethod, Integer> methodsCount = new HashMap<RequestMethod, Integer>();
	String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
	
	for (String beanDefinitionName : beanDefinitionNames) {
		Class<?> type = beanFactory.getType(beanDefinitionName);
		RestController annotation = type.getAnnotation(RestController.class);
		
		if (annotation != null) {
			Method[] methods = type.getMethods();
			processControllerMethods(methods, methodsCount);
		}
		
	}
	
	Integer allMethodCount = 0;
	for (Entry<RequestMethod, Integer> methodCount : methodsCount.entrySet()) {
		LOGGER.info("Http Method - {} : {}", methodCount.getKey(), methodCount.getValue());
		allMethodCount += methodCount.getValue();
	}
	
	LOGGER.info("All methods count: {}", allMethodCount);
	
	beanFactory.registerSingleton("httpMethodsCount", allMethodCount);
	beanFactory.registerSingleton("httpMethods", methodsCount);
}
 
开发者ID:ifnul,项目名称:ums-backend,代码行数:29,代码来源:WebServiceMethodCountBeanFactoryPostProcessor.java


注:本文中的org.springframework.web.bind.annotation.RestController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。