本文整理汇总了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;未经允许,请勿转载。 |
请发表评论