本文整理匯總了Java中org.springframework.web.servlet.view.RedirectView類的典型用法代碼示例。如果您正苦於以下問題:Java RedirectView類的具體用法?Java RedirectView怎麽用?Java RedirectView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RedirectView類屬於org.springframework.web.servlet.view包,在下文中一共展示了RedirectView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeChallenge
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping("/closeChallenge/{challengeId}")
public RedirectView closeChallenge(@PathVariable Long challengeId,
RedirectAttributes redirectAttributes) {
logger.debug("Closing challenge");
Challenge currentChallenge = challengeService.findOne(challengeId);
if (!challengeService.isParticipating(currentChallenge, userService.getCurrentUser())) {
logger.debug("User trying to close somebody else's challenge. Redirecting to /error.");
redirectAttributes.addFlashAttribute("message", "user not in challenge");
return new RedirectView("/error");
}
challengeService.closeChallenge(currentChallenge);
redirectAttributes.addFlashAttribute("message", "Challenge closed.");
return new RedirectView("/user");
}
示例2: signUp
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@GetMapping("/signup")
public RedirectView signUp(WebRequest webRequest,
@CookieValue(name = "NG_TRANSLATE_LANG_KEY", required = false, defaultValue = "\"en\"") String langKey) {
String providerId = null;
try {
Connection<?> connection = providerSignInUtils.getConnectionFromSession(webRequest);
providerId = connection.getKey().getProviderId();
socialService.createSocialUser(connection, langKey.replace("\"", ""));
return redirect(URIBuilder
.fromUri(TenantUtil.getApplicationUrl() + "/social-register/"
+ connection.getKey().getProviderId())
.queryParam("success", "true").build().toString());
} catch (Exception e) {
log.error("Exception creating social user: ", e);
return redirectOnError(providerId);
}
}
示例3: handleSignIn
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
private RedirectView handleSignIn(Connection<?> connection, ConnectionFactory<?> connectionFactory,
NativeWebRequest request) {
List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
if (userIds.isEmpty()) {
ProviderSignInAttempt signInAttempt = new ProviderSignInAttempt(connection);
sessionStrategy.setAttribute(request, ProviderSignInAttempt.SESSION_ATTRIBUTE, signInAttempt);
return redirect(getSignUpUrl());
} else if (userIds.size() == 1) {
usersConnectionRepository.createConnectionRepository(userIds.get(0)).updateConnection(connection);
String originalUrl = signInAdapter.signIn(userIds.get(0), connection, request);
return originalUrl != null ? redirect(originalUrl) : redirect(POST_SIGN_IN_URL);
} else {
log.error("Find more than one user with connection key: {}", connection.getKey());
return redirectOnError(connection.getKey().getProviderId());
}
}
示例4: rootController
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@Bean
protected Controller rootController() {
return new ParameterizableViewController() {
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final String queryString = request.getQueryString();
final String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
return new ModelAndView(new RedirectView(response.encodeURL(url)));
}
};
}
示例5: deleteRegisteredService
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
/**
* Method to delete the RegisteredService by its ID.
* @param request the HttpServletRequest
* @param response the HttpServletResponse
* @return the Model and View to go to after the service is deleted.
*/
public ModelAndView deleteRegisteredService(
final HttpServletRequest request, final HttpServletResponse response) {
final String id = request.getParameter("id");
final long idAsLong = Long.parseLong(id);
final ModelAndView modelAndView = new ModelAndView(new RedirectView(
"manage.html", true), "status", "deleted");
final RegisteredService r = this.servicesManager.delete(idAsLong);
modelAndView.addObject("serviceName", r != null
? r.getName() : "");
return modelAndView;
}
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:22,代碼來源:ManageRegisteredServicesMultiActionController.java
示例6: servicePortalFind
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping ( "/find-service/{releasePackage}/{serviceName}" )
public ModelAndView servicePortalFind (
@PathVariable String serviceName,
@PathVariable String releasePackage ) {
ModelAndView mav = new ModelAndView();
mav.setView( new RedirectView( CsapCoreService.ADMIN_URL, true, false, true ) );
logger.info( "Redirecting based on package {} and service {}", releasePackage, serviceName );
mav.getModel().put( CSAP.PACKAGE_PARAM, releasePackage );
// use the first instance to determine the default admin service
ServiceInstance instance = application
.serviceInstancesByName( releasePackage, serviceName )
.stream()
.findFirst()
.get();
mav.getModel().put( CSAP.SERVICE_PORT_PARAM, instance.getServiceName_Port() );
mav.getModel().put( CSAP.HOST_PARAM, instance.getHostName() );
return mav;
}
示例7: register
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
/**
* Registers a new {@link User} for the data provided by the given {@link UserForm}. Note, how an interface is used to
* bind request parameters.
*
* @param userForm the request data bound to the {@link UserForm} instance.
* @param binding the result of the binding operation.
* @param model the Spring MVC {@link Model}.
* @return
*/
@RequestMapping(method = RequestMethod.POST)
public Object register(UserForm userForm, BindingResult binding, Model model) {
userForm.validate(binding, userManagement);
if (binding.hasErrors()) {
return "users";
}
userManagement.register(new Username(userForm.getUsername()), Password.raw(userForm.getPassword()));
RedirectView redirectView = new RedirectView("redirect:/users");
redirectView.setPropagateQueryParams(true);
return redirectView;
}
示例8: startCreditApplicationProcess
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@PostMapping("/")
public RedirectView startCreditApplicationProcess() {
//Create Credit Application Number
UUID creditApplicationNumber = UUID.randomUUID();
Date applicationTime = new Date();
LOGGER.info("Created a new Credit Application Number: " + creditApplicationNumber.toString());
// We are saving the initial status
CreditApplicationStatus status = new CreditApplicationStatus(creditApplicationNumber.toString(), applicationTime);
repository.save(status);
LOGGER.info("Saved " + status.toString());
// We are sending a CreditApplicationNumberGeneratedEvent
CreditApplicationNumberGeneratedEvent event = new CreditApplicationNumberGeneratedEvent();
event.setApplicationNumber(creditApplicationNumber.toString());
event.setCreationTime(applicationTime);
applicationProcessChannels.creditApplicationNumberGeneratedOut()
.send(MessageBuilder.withPayload(event).build());
LOGGER.info("Sent " + event.toString());
return new RedirectView(nextProcessStepUrl + creditApplicationNumber.toString());
}
示例9: handleRequestInternal
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Player player = playerService.getPlayer(request, response);
List<TransferStatus> statuses = statusService.getStreamStatusesForPlayer(player);
MediaFile current = statuses.isEmpty() ? null : mediaFileService.getMediaFile(statuses.get(0).getFile());
MediaFile dir = current == null ? null : mediaFileService.getParentOf(current);
String url;
if (dir != null && !mediaFileService.isRoot(dir)) {
url = "main.view?id=" + dir.getId();
} else {
url = "home.view";
}
return new ModelAndView(new RedirectView(url));
}
示例10: handleRequestInternal
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<>();
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
User user = securityService.getCurrentUser(request);
String username = user.getUsername();
UserSettings userSettings = settingsService.getUserSettings(username);
Player player = playerService.getPlayer(request, response);
Playlist playlist = playlistService.getPlaylist(id);
if (playlist == null) {
return new ModelAndView(new RedirectView("notFound"));
}
map.put("playlist", playlist);
map.put("user", user);
map.put("player", player);
map.put("editAllowed", username.equals(playlist.getUsername()) || securityService.isAdmin(username));
map.put("partyMode", userSettings.isPartyModeEnabled());
return new ModelAndView("playlist","model",map);
}
示例11: playChallenge
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping("/playChallenge/{challengeId}")
public RedirectView playChallenge(RedirectAttributes redirectAttributes,
@PathVariable long challengeId) {
logger.debug("Playing challenge " + challengeId);
Challenge currentChallenge = challengeService.findOne(challengeId);
if (currentChallenge == null) {
redirectAttributes.addFlashAttribute("message", "challenge not found");
return new RedirectView("/error");
}
User player = userService.getCurrentUser();
TaskInstance unfinished = taskInstanceService.getUnfinishedInstanceInChallenge(
currentChallenge, player);
if (unfinished != null) {
logger.debug("Found unfinished instance. Redirecting to /task.");
return new RedirectView("/task/" + unfinished.getId());
}
if (currentChallenge.getType() == ChallengeType.ARCADE) {
return playArcade(redirectAttributes, currentChallenge);
} else if (currentChallenge.getIsOpen()) {
return playLive(currentChallenge, redirectAttributes);
}
return playPractice(redirectAttributes, currentChallenge);
}
示例12: newArcadeSession
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping("/newArcadeSession")
public RedirectView newArcadeSession(RedirectAttributes redirectAttributes,
@RequestParam String realm) {
logger.debug("Request to /newArcadeSession");
Realm currentRealm = null;
try {
logger.debug("Trying to get realm: {}", realm);
currentRealm = Realm.valueOf(realm.toUpperCase());
} catch (Exception e) {
logger.debug("Realm {} does not exist. Redirecting to /error.", realm);
return new RedirectView("/error");
}
Challenge challenge = arcadeChallengeService.getArcadeChallenge(currentRealm);
return playArcade(redirectAttributes, challenge);
}
示例13: playImplementationTurn
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
private RedirectView playImplementationTurn(RedirectAttributes redirectAttributes,
Challenge currentChallenge) {
logger.debug("Playing implementation turn");
Task implTask = liveChallengeService
.getTopmostImplementationTask(currentChallenge);
logger.debug("implementation task: " + implTask.toString());
Task testTask = liveChallengeService
.getTopmostTestTask(currentChallenge);
logger.debug("test task: " + testTask.toString());
TaskInstance testTaskInstance =
taskInstanceService.getByTaskAndUser(testTask, testTask.getAuthor());
logger.debug("Found uneven number of completed taskinstances, "
+ "current user has turn, "
+ "creating new task instance, redirecting to /task.");
return newTaskInstance(implTask, testTaskInstance, redirectAttributes);
}
示例14: playArcade
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
private RedirectView playArcade(RedirectAttributes redirectAttributes, Challenge challenge) {
logger.debug("Playing arcade");
if (taskInstanceService.getNumberOfDoneTaskInstancesInChallenge(challenge) % 2 == 0) {
logger.debug("User has test turn. Redirecting to /newtaskpair.");
return new RedirectView("/newtaskpair/" + challenge.getId());
} else {
Task implTask = arcadeChallengeService
.getRandomImplementationTask(challenge);
Task testTask = taskService.getCorrespondingTask(implTask);
TaskInstance testTaskInstance =
taskInstanceService.getByTaskAndUser(testTask, testTask.getAuthor());
logger.debug("User has implementation turn.");
return newTaskInstance(implTask, testTaskInstance, redirectAttributes);
}
}
示例15: task
import org.springframework.web.servlet.view.RedirectView; //導入依賴的package包/類
@RequestMapping(value = "/task", method = RequestMethod.POST)
public RedirectView task(String submissionCode,
long taskInstanceId,
RedirectAttributes redirectAttributes) throws IOException, ArchiveException {
logger.debug("Submitting task");
TaskInstance taskInstance = taskInstanceService.findOne(taskInstanceId);
Challenge currentChallenge = taskInstance.getTask().getChallenge();
Submission submission = submitToTmc(taskInstance, currentChallenge, submissionCode);
redirectAttributes.addFlashAttribute("submissionId", submission.getId().toString());
redirectAttributes.addFlashAttribute("taskInstance", taskInstance);
redirectAttributes.addFlashAttribute("challenge", currentChallenge);
redirectAttributes.addFlashAttribute("user", userService.getCurrentUser());
// Save user's answer from left editor
taskInstanceService.updateTaskInstanceCode(taskInstanceId, submissionCode);
logger.debug("Redirecting to feedback");
return new RedirectView("/feedback");
}