• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Controller类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: formPost

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
public Response formPost(@Valid @BeanParam FormDataBean form) {
    if (br.isFailed()) {
        ValidationError validationError = br.getAllValidationErrors().iterator().next();
        final ConstraintViolation<?> cv = validationError.getViolation();
        final String property = cv.getPropertyPath().toString();
        error.setProperty(property.substring(property.lastIndexOf('.') + 1));
        error.setValue(cv.getInvalidValue());
        error.setMessage(cv.getMessage());
        error.setParam(validationError.getParamName());
        return Response.status(BAD_REQUEST).entity("error.jsp").build();
    }
    return Response.status(OK).entity("data.jsp").build();
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:17,代码来源:FormController.java


示例2: onStartup

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@Override
public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException {
    servletContext.setAttribute(OZARK_CONTROLLERS_FOUND, false);
    if (classes != null && !classes.isEmpty()) {
        LOG.log(Level.INFO, "Ozark version {0} started", getClass().getPackage().getImplementationVersion());
        for (Class<?> clazz : classes) {
            final ApplicationPath ap = getAnnotation(clazz, ApplicationPath.class);
            if (ap != null) {
                if (servletContext.getAttribute(APP_PATH_CONTEXT_KEY) != null) {
                    // must be a singleton
                    throw new IllegalStateException("More than one JAX-RS ApplicationPath detected!");
                }
                servletContext.setAttribute(APP_PATH_CONTEXT_KEY, ap.value());
            }
            if (hasAnnotationOnClassOrMethod(clazz, Path.class)
                    && hasAnnotationOnClassOrMethod(clazz, Controller.class)) {
                servletContext.setAttribute(OZARK_CONTROLLERS_FOUND, true);
            }
            if (servletContext.getAttribute(APP_PATH_CONTEXT_KEY) != null
                    && (Boolean) servletContext.getAttribute(OZARK_CONTROLLERS_FOUND) == true) {
                break;  // no need to loop further
            }
        }
    }
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:26,代码来源:OzarkContainerInitializer.java


示例3: getReplacement

import javax.mvc.annotation.Controller; //导入依赖的package包/类
private <T> AnnotatedMethod<? super T> getReplacement(AnnotatedType<T> type,
                                                      AnnotatedMethod<? super T> method) {

    boolean isResourceMethod = method.getAnnotation(GET.class) != null ||
        method.getAnnotation(POST.class) != null || method.getAnnotation(PUT.class) != null ||
        method.getAnnotation(HEAD.class) != null || method.getAnnotation(DELETE.class) != null;

    boolean hasControllerAnnotation =
        method.getAnnotation(Controller.class) != null || type.getAnnotation(Controller.class) != null;

    if (isResourceMethod && hasControllerAnnotation) {

        log.log(Level.FINE, "Found controller method: {0}#{1}", new Object[]{
            type.getJavaClass().getName(),
            method.getJavaMember().getName()
        });

        return new AnnotatedMethodWrapper<>(
            method, Collections.singleton(() -> ValidationInterceptorBinding.class)
        );

    }

    return null;

}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:27,代码来源:AnnotatedTypeProcessor.java


示例4: createProduct

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Path("new")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String createProduct(@Valid
        @BeanParam Product entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.create(entity);
    return "redirect:product/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductController.java


示例5: editProduct

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("update/{id}")
@Controller
public String editProduct(@PathParam("id") Long id) {
    model.put("PRODUCT", facade.find(id));
    return "/view/product/update.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductController.java


示例6: updateProduct

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Path("update")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String updateProduct(@Valid
        @BeanParam Product entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.edit(entity);
    return "redirect:product/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductController.java


示例7: removeProduct

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("remove/{id}")
@Controller
public String removeProduct(@PathParam("id") Long id) {
    facade.remove(facade.find(id));
    return "redirect:product/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductController.java


示例8: findProduct

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("{id}")
@Controller
public String findProduct(@PathParam("id") Long id) {
    model.put("PRODUCT", facade.find(id));
    return "/view/product/view.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductController.java


示例9: findAllProduct

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("list")
@Controller
public String findAllProduct() {
    model.put("PRODUCT_LIST", facade.findAll());
    return "/view/product/list.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductController.java


示例10: createProductOrder

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Path("new")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String createProductOrder(@Valid
        @BeanParam ProductOrder entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.create(entity);
    return "redirect:productOrder/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductOrderController.java


示例11: editProductOrder

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("update/{id}")
@Controller
public String editProductOrder(@PathParam("id") Long id) {
    model.put("PRODUCT_ORDER", facade.find(id));
    return "/view/productOrder/update.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductOrderController.java


示例12: updateProductOrder

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Path("update")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String updateProductOrder(@Valid
        @BeanParam ProductOrder entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.edit(entity);
    return "redirect:productOrder/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:ProductOrderController.java


示例13: removeProductOrder

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("remove/{id}")
@Controller
public String removeProductOrder(@PathParam("id") Long id) {
    facade.remove(facade.find(id));
    return "redirect:productOrder/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductOrderController.java


示例14: findProductOrder

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("{id}")
@Controller
public String findProductOrder(@PathParam("id") Long id) {
    model.put("PRODUCT_ORDER", facade.find(id));
    return "/view/productOrder/view.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductOrderController.java


示例15: findAllProductOrder

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("list")
@Controller
public String findAllProductOrder() {
    model.put("PRODUCT_ORDER_LIST", facade.findAll());
    return "/view/productOrder/list.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:ProductOrderController.java


示例16: createCustomer

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Path("new")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String createCustomer(@Valid
        @BeanParam Customer entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.create(entity);
    return "redirect:customer/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:CustomerController.java


示例17: editCustomer

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("update/{id}")
@Controller
public String editCustomer(@PathParam("id") Long id) {
    model.put("CUSTOMER", facade.find(id));
    return "/view/customer/update.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:CustomerController.java


示例18: updateCustomer

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@POST
@Path("update")
@Controller
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfValid
public String updateCustomer(@Valid
        @BeanParam Customer entity) {
    if (validationResult.isFailed()) {
        return ValidationUtil.getResponse(validationResult, error);
    }
    facade.edit(entity);
    return "redirect:customer/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:14,代码来源:CustomerController.java


示例19: removeCustomer

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("remove/{id}")
@Controller
public String removeCustomer(@PathParam("id") Long id) {
    facade.remove(facade.find(id));
    return "redirect:customer/list";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:CustomerController.java


示例20: findCustomer

import javax.mvc.annotation.Controller; //导入依赖的package包/类
@GET
@Path("{id}")
@Controller
public String findCustomer(@PathParam("id") Long id) {
    model.put("CUSTOMER", facade.find(id));
    return "/view/customer/view.jsp";
}
 
开发者ID:jpamodeler,项目名称:JPA-Modeler-Examples,代码行数:8,代码来源:CustomerController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StubBuilder类代码示例发布时间:2022-05-21
下一篇:
Java VersionInfo类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap