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


Java WebUtils.setSessionAttribute方法代码示例

本文整理汇总了Java中org.springframework.web.util.WebUtils.setSessionAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java WebUtils.setSessionAttribute方法的具体用法?Java WebUtils.setSessionAttribute怎么用?Java WebUtils.setSessionAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.util.WebUtils的用法示例。


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

示例1: getQuickSearchPosts

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/quicksearch/page/{pageNumber}",
        produces = "text/html;charset=UTF-8")
public String getQuickSearchPosts(@PathVariable int pageNumber,
                                  HttpServletRequest request,
                                  CurrentUser currentUser) {
    String search = (String) WebUtils.getSessionAttribute(request, SESSION_QUICKSEARCH_QUERY);
    String result;
    List<PostDoc> postDocs = postDocService.doQuickSearch(search);
    if (postDocs.size() == 0) {
        result = fmService.getNoResultsMessage(search);
    } else {
        Slice<PostDoc> posts = postDocService.doPagedQuickSearch(search, pageNumber, POST_PAGING_SIZE);
        result = populatePostDocStream(posts.getContent(), currentUser);
        WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_QUICKSEARCH_POSTS, posts.getContent());
    }
    return result;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:18,代码来源:PostsRestController.java

示例2: getPostsByLikes

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/likes/{userId}/page/{pageNumber}",
        produces = "text/html;charset=UTF-8")
public String getPostsByLikes(@PathVariable long userId,
                              @PathVariable int pageNumber,
                              HttpServletRequest request,
                              CurrentUser currentUser) {
    List<Post> posts = postService.getPostsByUserLikes(userId);
    String result;
    if (posts == null) {
        result = fmService.getNoLikesMessage();
    } else {
        posts = postService.getPagedLikedPosts(userId, pageNumber, POST_PAGING_SIZE);
        result = populatePostStream(posts, currentUser);
        WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_LIKEDPOSTS, posts);
    }
    return result;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:18,代码来源:PostsRestController.java

示例3: addPostLink

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/add/{type}", method = GET)
public String addPostLink(@PathVariable("type") String type, Model model, HttpServletRequest request) {
    PostType postType = PostType.valueOf(type.toUpperCase());
    model.addAttribute("postDTO", new PostDTO());
    model.addAttribute("canPreview", false);
    model.addAttribute("categories", postService.getAdminSelectionCategories());
    if (postType == PostType.POST) {
        WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_NEWPOST, null);
        model.addAttribute("hasPost", true);
        model.addAttribute("postheader", webUI.getMessage(ADD_POST_HEADER));
        return ADMIN_POST_ADD_VIEW;
    } else {
        model.addAttribute("postLink", new PostLink());
        model.addAttribute("postheader", webUI.getMessage(ADD_LINK_HEADER));
        return ADMIN_LINK_ADD_VIEW;
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:18,代码来源:AdminPostsController.java

示例4: addLink

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/add/link", params = {"isLink"}, method = GET)
public String addLink(@RequestParam(value = "isLink") Boolean isLink,
                      @Valid PostLink postLink, BindingResult result, Model model, HttpServletRequest request) {
    model.addAttribute("postheader", webUI.getMessage(ADD_LINK_HEADER));
    if (StringUtils.isEmpty(postLink.getLink())) {
        result.rejectValue("link", "post.link.is.empty");
    } else {
        PagePreviewDTO pagePreview = jsoupService.getPagePreview(postLink.getLink());
        if (pagePreview == null) {
            result.rejectValue("link", "post.link.page.not.found");
            return ADMIN_LINK_ADD_VIEW;
        } else {
            model.addAttribute("categories", postService.getAdminSelectionCategories());
            model.addAttribute("hasLink", true);
            model.addAttribute("hasCarousel", true);
            WebUtils.setSessionAttribute(request, "pagePreview", pagePreview);
            model.addAttribute("pagePreview", pagePreview);
            model.addAttribute("postDTO",
                    postDtoFromPagePreview(pagePreview, postLink.getLink()));
        }
    }
    return ADMIN_LINK_ADD_VIEW;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:24,代码来源:AdminPostsController.java

示例5: saveTimeoutSession

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
private void saveTimeoutSession(final HttpServletRequest request) {
  StringBuilder params = new StringBuilder("?");
  Map<String, String[]> parameterMap = request.getParameterMap();
  for (Map.Entry<String, String[]> item : parameterMap.entrySet()) {
    params.append(item.getKey() + "=" + item.getValue()[0] + "&");
  }

  // request.getRequestURI(); // /dxbase/daily/display
  // request.getRequestURL(); //
  // http://10.7.210.7:8080/dxbase/daily/display

  WebUtils.setSessionAttribute(request, Constants.SESSION_TIMEOUT_URI,
      request.getRequestURI().substring(request.getContextPath().length()));
  WebUtils.setSessionAttribute(request, Constants.SESSION_TIMEOUT_REQUEST_PARAMETERS, params);
  WebUtils.setSessionAttribute(request, Constants.SESSION_TIMEOUT_REQUEST_METHOD, request.getMethod());
}
 
开发者ID:nickevin,项目名称:Qihua,代码行数:17,代码来源:SecurityInterceptor.java

示例6: save

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/save", method = RequestMethod.POST)
public @ResponseBody JSONResponseBody save(final HttpServletRequest request, final Member member) {
  try {
    memberService.save(member);

    Member session = (Member) WebUtils.getSessionAttribute(request, Constants.SESSION_MEMBER);
    member.setScore(session.getScore());

    WebUtils.setSessionAttribute(request, Constants.SESSION_MEMBER, member);
    // WebUtils.setSessionAttribute(request, "__changed__", "");
  } catch (Exception e) {
    e.printStackTrace();

    return new JSONResponseBody(false, "保存失败,请联系网站管理员。");
  }

  return new JSONResponseBody();
}
 
开发者ID:nickevin,项目名称:Qihua,代码行数:19,代码来源:MemberController.java

示例7: isMobileAccess

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
/**
 * 判断是否是手机访问
 */
public static boolean isMobileAccess(HttpServletRequest request) {
	boolean isFromMobile = false;
	// 检查是否已经记录访问方式(移动端或pc端)
	Object ua = WebUtils.getSessionAttribute(request, "ua");
	if (null == ua) {
		try {
			String userAgent = request.getHeader("USER-AGENT").toLowerCase();
			if (null == userAgent) {
				userAgent = "";
			}
			isFromMobile = checkUserAgent(userAgent);
			// 判断是否为移动端访问
			if (isFromMobile) {
				WebUtils.setSessionAttribute(request, "ua", "mobile");
			} else {
				WebUtils.setSessionAttribute(request, "ua", "pc");
			}
		} catch (Exception e) {
		}
	} else {
		isFromMobile = ua.equals("mobile");
	}

	return isFromMobile;
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:29,代码来源:WebHelper.java

示例8: login

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@GetMapping("/login")
public String login(HttpServletRequest request) {
    try {
        OAuthClientRequest oauthResponse = OAuthClientRequest
                .authorizationLocation(authorize_url)
                .setResponseType(OAuth.OAUTH_CODE)
                .setClientId(clientId)
                .setRedirectURI(server + OAUTH_WEIBO_CALLBACK)
                .setState(STATE_LOGIN)
                .buildQueryMessage();
        WebUtils.setSessionAttribute(request, "state", STATE_LOGIN);
        return "redirect:"+oauthResponse.getLocationUri();
    } catch (OAuthSystemException e) {
        e.printStackTrace();
    }

    return "redirect:/500";
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:19,代码来源:WeiboOAuthClient.java

示例9: searchPage

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/search", method = GET)
public String searchPage(Model model, HttpServletRequest request) {
    model.addAttribute("postQueryDTO", new PostQueryDTO());
    model.addAttribute("isSearchResult", false);
    WebUtils.setSessionAttribute(request, SESSION_POSTQUERYDTO, null);
    return POSTS_SEARCH_VIEW;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:8,代码来源:PostsController.java

示例10: searchPageResults

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/search",  params = {"query"}, method = GET)
public String searchPageResults(@Valid PostQueryDTO postQueryDTO,
                                BindingResult result, Model model, HttpServletRequest request) {
    model.addAttribute("postQuery", postQueryDTO);
    if (result.hasErrors()) {
        return POSTS_SEARCH_VIEW;
    } else {
        WebUtils.setSessionAttribute(request, SESSION_POSTQUERYDTO, postQueryDTO);
        model.addAttribute("isSearchResult", true);
        return POSTS_SEARCH_VIEW;
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:13,代码来源:PostsController.java

示例11: quicksearch

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "", params = {"search"}, method = GET)
public String quicksearch(Model model, String search, HttpServletRequest request) {
    List<PostDoc> postDocs = postDocService.doQuickSearch(search);

    boolean showMore = postDocs.size() > POST_PAGING_SIZE;
    boolean hasQuickSearchResults = postDocs.size() > 0;

    WebUtils.setSessionAttribute(request, SESSION_QUICKSEARCH_QUERY, search);
    model.addAttribute("showmore", showMore);
    model.addAttribute("query", search);
    model.addAttribute("hasResults", hasQuickSearchResults);
    return POSTS_QUICKSEARCH_VIEW;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:14,代码来源:PostsController.java

示例12: getPostTitles

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/titles/page/{pageNumber}", produces = "text/html;charset=UTF-8")
    public String getPostTitles(@PathVariable Integer pageNumber, HttpServletRequest request, CurrentUser currentUser) {
//        Slice<Post> posts = postService.getPublishedPosts(pageNumber, TITLE_PAGING_SIZE);
        Slice<Post> posts = postService.getPagedPostsByPostType(PostType.POST, pageNumber, TITLE_PAGING_SIZE);
        String result = populatePostStream(posts.getContent(), currentUser, TITLE_TEMPLATE);
        WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_POSTTITLES, posts.getContent());
        return result;
    }
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:9,代码来源:PostsRestController.java

示例13: getLinks

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/links/page/{pageNumber}", produces = "text/html;charset=UTF-8")
public String getLinks(@PathVariable Integer pageNumber, HttpServletRequest request, CurrentUser currentUser) {
    Slice<Post> posts = postService.getPagedPostsByPostType(PostType.LINK, pageNumber, POST_PAGING_SIZE);
    String result;
    if (applicationSettings.getTitleStreamDisplay())
        result = populatePostStream(posts.getContent(), currentUser, TITLE_TEMPLATE);
    else
        result = populatePostStream(posts.getContent(), currentUser);
    if (StringUtils.isEmpty(result)) {
        result = fmService.getNoLinksMessage();
    }
    WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_JUSTLINKS, posts.getContent());
    return result;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:15,代码来源:PostsRestController.java

示例14: getPostTitlesByTagId

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/titles/tag/{tagid}/page/{pageNumber}",
        produces = "text/html;charset=UTF-8")
public String getPostTitlesByTagId(@PathVariable long tagid,
                                   @PathVariable int pageNumber,
                                   HttpServletRequest request,
                                   CurrentUser currentUser) {
    Slice<Post> posts = postService.getPublishedPostsByTagId(tagid, pageNumber, TITLE_PAGING_SIZE);
    String result = populatePostStream(posts.getContent(), currentUser, TITLE_TEMPLATE);
    WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_TAGPOSTTITLES, posts.getContent());
    return result;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:12,代码来源:PostsRestController.java

示例15: getPosts

import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/page/{pageNumber}", produces = "text/html;charset=UTF-8")
    public String getPosts(@PathVariable Integer pageNumber, HttpServletRequest request, CurrentUser currentUser) {
//        Slice<Post> posts = postService.getPublishedPosts(pageNumber, POST_PAGING_SIZE);
        boolean titleDisplay = applicationSettings.getTitleStreamDisplay();
        int pagingSize = titleDisplay ? TITLE_PAGING_SIZE : POST_PAGING_SIZE;
        Slice<Post> posts = postService.getPagedPostsByPostType(PostType.POST, pageNumber, TITLE_PAGING_SIZE);
        String template = titleDisplay ? "title" : null;
        String result = populatePostStream(posts.getContent(), currentUser, template);
        WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_POSTS, posts.getContent());
        return result;
    }
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:12,代码来源:PostsRestController.java


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