本文整理汇总了Java中org.springframework.web.util.WebUtils.getSessionAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java WebUtils.getSessionAttribute方法的具体用法?Java WebUtils.getSessionAttribute怎么用?Java WebUtils.getSessionAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.util.WebUtils
的用法示例。
在下文中一共展示了WebUtils.getSessionAttribute方法的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;
}
示例2: registerWithToken
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="joinGameToken")
@ResponseBody
public String registerWithToken(HttpServletRequest request,
HttpServletResponse response,
String key) {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
RegistrationKey rk = new RegistrationKey();
boolean openRegFailed = false;
if (key != null) {
Long gameId = rk.keyToGameId(key);
logger.info("found openreg cookie for member " + userSession.getMemberId());
PlayerService.InviteStatus status =
playerService.inviteMember(gameId, userSession.getMemberId());
if (status != InviteStatus.SUCCESS) {
openRegFailed = true;
}
}
return openRegFailed ? "failed" : "success";
}
示例3: settings
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="/game/settings", method=RequestMethod.GET)
public String settings(Model model, HttpServletRequest request) {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
PlayerData player = userSession.getPlayerData();
GameDescriptionData gdd = userSession.getGameDesc();
if (player.getIsMaster()) {
if (gdd.getStatus() == STATUS.REGISTERING) {
List<PlayerData> players = playerService.getPlayersInGame(gdd.getId());
model.addAttribute("registeredPlayers", players);
model.addAttribute("invitedPlayers", gameService.getInvites(gdd.getId()));
model.addAttribute("regkey", new RegistrationKey().gameIdToKey(userSession.getGameId()));
}
else {
model.addAttribute("players", playerService.getPlayersInGame(gdd.getId()));
}
model.addAttribute("gameDesc", userSession.getGameDesc());
return "game/gameSettingsAuthor";
}
else {
return "game/gameSettings";
}
}
示例4: onSubmit
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="/make", method=RequestMethod.POST)
protected String onSubmit(
HttpServletRequest request, HttpServletResponse response,
QuestionData q,
ModelMap model,
SessionStatus status)
throws Exception {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
PlayerData player = playerService.findPlayer(userSession.getGameId(), userSession.getMemberId());
if (request.getParameterMap().containsKey("delete")) {
// delete all queued questions by sending empty list to reorder to.
ArrayList<Integer> emptyList = new ArrayList<Integer>();
playerService.reorderQueuedQuestions(player.getId(),emptyList);
// clear question in session now.
status.setComplete();
return "redirect:make";
}
else {
logger.debug("makequestion post playerid="+player.getId()+" qid="+q.getId()+" imageId="+q.getImageId());
logger.debug("================> qid="+q.getId());
request.getSession().setAttribute("qsess", q); // put question is session so it can be grabbed for verify and submit.
return "redirect:preview";
}
}
示例5: over
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="/game/over", method=RequestMethod.GET)
public String over(Model model, HttpServletRequest request) {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
model.addAttribute("gameDesc", userSession.getGameDesc());
long gameId = userSession.getGameId();
List<PlayerData> players = playerService.getActivePlayersInGame(gameId);
// Sort by score
Collections.sort(players, new Comparator<PlayerData>() {
public int compare(PlayerData o1, PlayerData o2) {
return (int) (o2.getScore() - o1.getScore());
}});
model.addAttribute("players", players);
model.addAttribute("rounds", gameService.getCompletedRounds(gameId));
model.addAttribute("comments", gameService.getGameComments(gameId));
// just in case user was last one to answer in game....
if (userSession.getTemps().containsKey("answered")) {
model.addAttribute("answered", userSession.getTemps().get("answered"));
userSession.getTemps().remove("answered");
}
return "game/gameOver";
}
示例6: resolveLocaleContext
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@Override
public LocaleContext resolveLocaleContext(final HttpServletRequest request) {
return new TimeZoneAwareLocaleContext() {
@Override
public Locale getLocale() {
Locale locale = (Locale) WebUtils.getSessionAttribute(request, LOCALE_SESSION_ATTRIBUTE_NAME);
if (locale == null) {
locale = determineDefaultLocale(request);
}
return locale;
}
@Override
public TimeZone getTimeZone() {
TimeZone timeZone = (TimeZone) WebUtils.getSessionAttribute(request, TIME_ZONE_SESSION_ATTRIBUTE_NAME);
if (timeZone == null) {
timeZone = determineDefaultTimeZone(request);
}
return timeZone;
}
};
}
示例7: getFullSearchPosts
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/search/page/{pageNumber}",
produces = "text/html;charset=UTF-8")
public String getFullSearchPosts(@PathVariable int pageNumber,
HttpServletRequest request,
CurrentUser currentUser) {
PostQueryDTO postQueryDTO =
(PostQueryDTO) WebUtils.getSessionAttribute(request, SESSION_POSTQUERYDTO);
String result = null;
List<PostDoc> postDocs = null;
if (postQueryDTO != null) {
try {
postDocs = postDocService.doFullSearch(postQueryDTO);
} catch (UncategorizedSolrException ex) {
logger.info(MessageFormat.format("Bad Query: {0}", postQueryDTO.getQuery()));
return fmService.getNoResultsMessage(postQueryDTO.getQuery());
}
if (postDocs.size() == 0) {
result = fmService.getNoResultsMessage(postQueryDTO.getQuery());
} else {
Slice<PostDoc> postDocSlice =
postDocService.doPagedFullSearch(postQueryDTO, pageNumber, POST_PAGING_SIZE);
result = populatePostDocStream(postDocSlice.getContent(), currentUser);
WebUtils.setSessionAttribute(request,
SESSION_ATTRIBUTE_FULLSEARCH_POSTS, postDocSlice.getContent());
}
}
return result;
}
示例8: hasNext
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private String hasNext(HttpServletRequest request, String attribute, int pagingSize) {
List<Post> posts = (List<Post>) WebUtils.getSessionAttribute(request, attribute);
if (posts != null)
return Boolean.toString(posts.size() >= pagingSize);
else
return "true";
}
示例9: inviteResponse
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="inviteResponse", method=RequestMethod.POST)
public String inviteResponse(@RequestParam("gameId") long gameId, HttpServletRequest request) {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
boolean wasAccepted = (request.getParameterMap().containsKey("accept"));
playerService.registrationResponse(userSession.getMemberId(), gameId, wasAccepted);
if (wasAccepted) {
userSession.setGameId(gameId);
return "redirect:/game/game";
}
else {
return "redirect:/member/gameList";
}
}
示例10: gameDelete
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
protected void gameDelete(HttpServletRequest request)
{
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
GameDescriptionData gd = userSession.getGameDesc();
gameService.endGame(gd.getId());
userSession.setGameDesc(null);
userSession.setGameId(-1);
}
示例11: profile
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/profile")
public String profile(HttpServletRequest request) {
try {
User sessionUser = (User) WebUtils.getSessionAttribute(request, Constants.SESSION_USER);
User user = userService.find(sessionUser.getUserId());
request.setAttribute("user", user);
} catch (Exception e) {
log.error(ExceptionUtils.getStackTraceAsString(e));
e.printStackTrace();
}
return "/console/user/profile";
}
示例12: QueryParameter
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
public QueryParameter() {
try {
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
sessionUser = (User) WebUtils.getSessionAttribute(request, Constants.SESSION_USER);
} catch (Exception e) {
log.debug("未登录,无法获取 session。");
}
}
示例13: makeGet
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="/make", method=RequestMethod.GET)
public String makeGet(HttpServletRequest request, ModelMap model, SessionStatus status) {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
logger.info("masterCreate2 shown for member id = " + userSession.getMemberId());
QuestionData q = (QuestionData) WebUtils.getSessionAttribute(request, "qsess");
if (q != null) {
logger.debug("Got question from session");
Boolean isVerified = null;
try {
isVerified = ServletRequestUtils.getBooleanParameter(request, "verified");
} catch (ServletRequestBindingException e) {
logger.warn("make question session entered without verified? Clear session");
}
if (isVerified != null) {
model.addAttribute("verified", isVerified);
}
else {
// has session, but not an edit (no verified flag). Clear session and go through normal processing
q=null;
}
}
if (q == null) {
PlayerData player = playerService.findPlayer(userSession.getGameId(), userSession.getMemberId());
List<QuestionData> qqs = playerService.getQueuedQuestions(player.getId());
if (qqs.size() > 0) {
q = qqs.get(0);
logger.debug("Got queued question.");
}
else {
logger.debug("Creating question as none in session or id.");
q = new QuestionData();
}
}
model.addAttribute("question", q);
logger.debug("================> qid="+q.getId());
return "game/masterCreate2";
}
示例14: handleRequest
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="main")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
ModelAndView mav = new ModelAndView("admin/main");
mav.addObject("games", gameService.getAllGames());
mav.addObject("members", memberService.findAllMembers());
return mav;
}
示例15: handleGetRequest
import org.springframework.web.util.WebUtils; //导入方法依赖的package包/类
@RequestMapping(value="/make", method=RequestMethod.GET)
public String handleGetRequest(HttpServletRequest request, ModelMap model, SessionStatus status) {
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
logger.info("Gamequeue shown for member id = " + userSession.getMemberId());
QuestionData q = (QuestionData) WebUtils.getSessionAttribute(request, "qsess");
if (q != null) {
logger.debug("Got question from session");
Boolean isVerified = null;
try {
isVerified = ServletRequestUtils.getBooleanParameter(request, "verified");
} catch (ServletRequestBindingException e) {
logger.warn("make question session entered without verified? Clear session");
}
if (isVerified != null) {
model.addAttribute("verified", isVerified);
}
else {
// has session, but not an edit (no verified flag). Clear session and go through normal processing
q=null;
}
}
if (q == null) {
PlayerData player = playerService.findPlayer(userSession.getGameId(), userSession.getMemberId());
List<QuestionData> qqs = playerService.getQueuedQuestions(player.getId());
if (qqs.size() > 0) {
q = qqs.get(0);
logger.debug("Got queued question.");
}
else {
logger.debug("Creating question as none in session or id.");
q = new QuestionData();
}
}
model.addAttribute("question", q);
logger.debug("================> qid="+q.getId());
return "game/gameQueue";
}