Java Code Examples for org.springframework.web.servlet.view.RedirectView#setStatusCode()
The following examples show how to use
org.springframework.web.servlet.view.RedirectView#setStatusCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OauthController.java From kaif with Apache License 2.0 | 6 votes |
private RedirectView redirectViewWithQuery(String redirectUri, String state, String query) { if (!Strings.isNullOrEmpty(state)) { query += "&state=" + state; } String encoded = UriUtils.encodeQuery(query, Charsets.UTF_8.name()); String locationUri = redirectUri; if (redirectUri.contains("?")) { locationUri += "&" + encoded; } else { locationUri += "?" + encoded; } RedirectView redirectView = new RedirectView(locationUri); redirectView.setStatusCode(HttpStatus.FOUND); redirectView.setExposeModelAttributes(false); redirectView.setPropagateQueryParams(false); return redirectView; }
Example 2
Source File: CategoryController.java From podcastpedia-web with MIT License | 6 votes |
/** * Custom handler for displaying a podcast. * * @param podcastId * @param episode * @return */ @RequestMapping(value="{categoryId}/*", method=RequestMethod.GET) public ModelAndView getPodcastsFromCategory(@PathVariable("categoryId") int categoryId, ModelMap model){ LOG.debug("------ CategoryController.getPodcastsFromCategory : redirects to search podcasts from a given category -----"); StringBuffer queryString = new StringBuffer(); queryString.append("?numberResultsPerPage=10"); queryString.append("&searchTarget=podcasts"); queryString.append("&categId=" + categoryId); queryString.append("&searchMode=natural"); queryString.append("¤tPage=1"); String url = "/search/advanced_search/results" + queryString.toString(); RedirectView rv = new RedirectView(); rv.setStatusCode(HttpStatus.MOVED_PERMANENTLY); rv.setUrl(url); ModelAndView mv = new ModelAndView(rv); return mv; }
Example 3
Source File: TagController.java From podcastpedia-web with MIT License | 6 votes |
/** * Custom handler for displaying a podcast. * * @param podcastId * @param episode * @return */ @RequestMapping(value = "{tagId}/*", method = RequestMethod.GET) public ModelAndView getPodcastsWithTag( @PathVariable("tagId") Integer tagId, ModelMap model) { LOG.debug("------ CategoryController.getPodcastsFromCategory : redirects to search podcasts from a given category -----"); StringBuffer queryString = new StringBuffer(); queryString.append("?numberResultsPerPage=10"); queryString.append("&searchTarget=podcasts"); queryString.append("&tagId=" + tagId); queryString.append("&searchMode=natural"); queryString.append("¤tPage=1"); String url = "/search/advanced_search/results" + queryString.toString(); RedirectView rv = new RedirectView(); rv.setStatusCode(HttpStatus.MOVED_PERMANENTLY); rv.setUrl(url); ModelAndView mv = new ModelAndView(rv); return mv; }
Example 4
Source File: UserController.java From kaif with Apache License 2.0 | 5 votes |
@RequestMapping("/u/{username}") public Object userProfile(@PathVariable("username") String username) { Account account = accountService.loadAccount(username); if (!account.getUsername().equals(username)) { RedirectView redirectView = new RedirectView("/u/" + account.getUsername()); redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY); return redirectView; } AccountStats accountStats = accountService.loadAccountStats(account.getUsername()); List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername()); return new ModelAndView("account/user-profile")// .addObject("account", account) .addObject("accountStats", accountStats) .addObject("administerZones", zones); }
Example 5
Source File: DeveloperController.java From kaif with Apache License 2.0 | 4 votes |
@RequestMapping("") public RedirectView root() { RedirectView redirectView = new RedirectView("/developer/doc"); redirectView.setStatusCode(HttpStatus.TEMPORARY_REDIRECT); return redirectView; }