本文整理汇总了Java中org.glassfish.jersey.server.mvc.Template类的典型用法代码示例。如果您正苦于以下问题:Java Template类的具体用法?Java Template怎么用?Java Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Template类属于org.glassfish.jersey.server.mvc包,在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addComment
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@POST
@Path("/{id}/comment")
@Template(name = "/post/showPosts.ftl")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String addComment(@PathParam("id") String fPostId,
@FormParam("message") String fCommentBody) throws IOException {
User authUser = (User) securityContext.getUserPrincipal();
Comment comment = new Comment();
comment.setPostId(Integer.parseInt(fPostId));
comment.setMessage(fCommentBody);
comment.setUserId((int) authUser.getId());
comment.saveIt();
response.sendRedirect("/post/" + fPostId);
return "";
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:20,代码来源:PostResource.java
示例2: createEnhancingMethods
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
/**
* Creates enhancing methods for given resource.
*
* @param resourceClass resource class for which enhancing methods should be created.
* @param resourceInstance resource instance for which enhancing methods should be created. May be {@code null}.
* @param newMethods list to store new methods into.
*/
private void createEnhancingMethods(final Class<?> resourceClass, final Object resourceInstance,
final List<ModelProcessorUtil.Method> newMethods) {
final Template template = resourceClass.getAnnotation(Template.class);
if (template != null) {
final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(resourceClass);
final List<MediaType> produces = MediaTypes
.createQualitySourceMediaTypes(annotatedResourceClass.getAnnotation(Produces.class));
final List<MediaType> consumes = MediaTypes.createFrom(annotatedResourceClass.getAnnotation(Consumes.class));
final TemplateInflectorImpl inflector = new TemplateInflectorImpl(template.name(),
resourceClass, resourceInstance);
newMethods.add(new ModelProcessorUtil.Method(HttpMethod.GET, consumes, produces, inflector));
newMethods.add(new ModelProcessorUtil.Method(IMPLICIT_VIEW_PATH_PARAMETER_TEMPLATE, HttpMethod.GET,
consumes, produces, inflector));
}
}
开发者ID:icode,项目名称:ameba,代码行数:27,代码来源:TemplateModelProcessor.java
示例3: listAction
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Template(name = "/post/list")
public ViewData listAction(@DefaultValue("1") @QueryParam("page") int page) {
int postsPerPage = Configuration.POSTS_PER_PAGE;
Paginator p = new Paginator(Post.class, postsPerPage, "*").orderBy("created_at desc");
int pageCount = Math.max((int) p.pageCount(), 1);
int pageNumber = (page > pageCount) ? pageCount : Math.max(1, page);
LazyList posts = p.getPage(pageNumber);
ViewData.set("model", posts);
HashMap<String, Object> pagination = new HashMap<>();
pagination.put("currentPage", pageNumber);
pagination.put("totalPages", pageCount);
pagination.put("linkUrl", RESOURCE_PATH);
ViewData.set("pagination", pagination);
return ViewData;
}
开发者ID:autoschool,项目名称:splinter,代码行数:21,代码来源:PostResource.java
示例4: editPostAction
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@POST
@Path("/{id}/edit")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Template(name= "/post/single")
public Response editPostAction(@PathParam("id") int id,
@FormParam("title")
@Pattern(regexp = "^(?!\\s*$).+", message = "empty string") String title,
@FormParam("content")
@Pattern(regexp = "^(?!\\s*$).+", message = "empty string") String content){
Post post=Post.findById(id);
post.setTitle(title);
post.setContent(content);
post.saveIt();
URI targetURIForRedirection = URI.create(RESOURCE_PATH + post.getId());
return Response.seeOther(targetURIForRedirection).build();
}
开发者ID:autoschool,项目名称:splinter,代码行数:17,代码来源:PostResource.java
示例5: editPost
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@POST
@AuthenticationRequired
@Path("/edit/{id}")
@Template(name = "/post/showPost.ftl")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Post editPost(@PathParam("id") int id,
@FormParam("title") String title,
@FormParam("body") String body) {
Post post = Post.findById(id);
if (post != null) {
post.setTitle(title);
post.setBody(body);
post.save();
}
return post;
}
开发者ID:autoschool,项目名称:baguette,代码行数:17,代码来源:PostResource.java
示例6: allUsers
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Template
@RolesAllowed({"user"})
@Path("/secure")
public SecureDto allUsers(@Context SecurityContext context) {
SecureDto secureDto = new SecureDto();
secureDto.setUsers(dao.all());
secureDto.setCurrentUser((User) context.getUserPrincipal());
return secureDto;
}
开发者ID:maugern,项目名称:jersey-skeleton,代码行数:11,代码来源:SecureViews.java
示例7: getByLocation
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/absolute")
@Template(name = "/hello.vm")
public TreeMap<String, String> getByLocation() {
return new TreeMap<String, String>() {{
put("name", "absolute");
}};
}
开发者ID:Feng-Zihao,项目名称:jersey-mvc-velocity,代码行数:9,代码来源:VelocityTemplateTest.java
示例8: getHelloByName
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/withoutSuffix")
@Template(name = "/hello")
public TreeMap<String, String> getHelloByName() {
return new TreeMap<String, String>() {{
put("name", "withoutSuffix");
}};
}
开发者ID:Feng-Zihao,项目名称:jersey-mvc-velocity,代码行数:9,代码来源:VelocityTemplateTest.java
示例9: showRegisterForm
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/register")
@Template(name = "/auth/register.ftl")
public ViewData showRegisterForm() {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:12,代码来源:AuthResource.java
示例10: showIndex
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/")
@Template(name = "/post/showPosts.ftl")
public ViewData showIndex() {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.posts = Post.findAll();
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:13,代码来源:IndexResource.java
示例11: showUser
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/{id}")
@Template(name = "/user/profile.ftl")
public ViewData showUser(@PathParam("id") int id) {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.profile = User.findById(id);
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:10,代码来源:UserResource.java
示例12: showUserposts
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/{id}/allposts")
@Template(name = "/user/posts.ftl")
public ViewData showUserposts(@PathParam("id") int id) {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.posts = Post.findAll();
view.profile = User.findById(id);
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:11,代码来源:UserResource.java
示例13: showUsers
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/all")
@Template(name = "/user/showUsers.ftl")
public ViewData showUsers() {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.users = User.findAll();
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:10,代码来源:UserResource.java
示例14: showRegisterForm
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/editprofile")
@Template(name = "/user/editprofile.ftl")
public ViewData showRegisterForm() {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:12,代码来源:UserResource.java
示例15: showPost
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/{id}")
@Template(name = "/post/showPost.ftl")
public ViewData showPost(@PathParam("id") int id) {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.post = Post.findById(id);
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:10,代码来源:PostResource.java
示例16: showPosts
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/all")
@Template(name = "/post/showPosts.ftl")
public ViewData showPosts() {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.posts = Post.findAll();
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:10,代码来源:PostResource.java
示例17: newPost
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/new")
@Template(name = "/post/newPost.ftl")
public ViewData newPost() {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.post = new Post();
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:10,代码来源:PostResource.java
示例18: editPost
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@GET
@Path("/edit/{id}")
@Template(name = "/post/editPost.ftl")
public ViewData editPost(@PathParam("id") int id) {
ViewData view = new ViewData();
view.authUser = (User) securityContext.getUserPrincipal();
view.post = Post.findById(id);
return view;
}
开发者ID:autoschool,项目名称:ya.blogo,代码行数:10,代码来源:PostResource.java
示例19: createPost
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
@POST
@Path("/")
@Template(name = "/post/showPost.ftl")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Post createPost(@FormParam("title") String title,
@FormParam("body") String body) {
Post post = new Post();
post.setTitle(title);
post.setBody(body);
post.saveIt();
return post;
}
开发者ID:autoschool,项目名称:switter,代码行数:13,代码来源:PostResources.java
示例20: aroundWriteTo
import org.glassfish.jersey.server.mvc.Template; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
final Object entity = context.getEntity();
if (!(entity instanceof Viewable) && resourceInfoProvider.get().getResourceMethod() != null) {
final Template template = TemplateHelper.getTemplateAnnotation(context.getAnnotations());
if (template != null) {
context.setType(Viewable.class);
context.setEntity(new Viewable(template.name(), entity));
}
}
context.proceed();
}
开发者ID:icode,项目名称:ameba,代码行数:18,代码来源:TemplateMethodInterceptor.java
注:本文中的org.glassfish.jersey.server.mvc.Template类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论