InternalResourceView view = new InternalResourceView(forwardUrl); return applyLifecycleMethods(FORWARD_URL_PREFIX, view);
InternalResourceView view = new InternalResourceView(forwardUrl); return applyLifecycleMethods(FORWARD_URL_PREFIX, view);
@Test public void returnView() throws Exception { InternalResourceView view = new InternalResourceView("testView"); this.handler.handleReturnValue(view, createReturnValueParam("view"), this.mavContainer, this.webRequest); assertSame(view, this.mavContainer.getView()); }
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try { if (request.getContextPath().equals(contextName)) { throw new IllegalStateException( getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf")); } executeAction(contextName); } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.error("Error during invocation", e); return new ModelAndView(new InternalResourceView(getViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName() + (isPassQueryString() ? "?" + request.getQueryString() : ""))); }
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { String sessionId = ServletRequestUtils.getStringParameter(request, "sid"); Session session = context.getManager().findSession(sessionId); if (session != null) { session.expire(); } return new ModelAndView(new InternalResourceView(getViewName())); }
private View getViewInternal(String viewPath, RequestContext context, ApplicationContext flowContext) { if (viewPath.endsWith(".jsp") || viewPath.endsWith(".jspx")) { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(flowContext); return view; } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(flowContext); return view; } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]"); } } }
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try { if (request.getContextPath().equals(contextName)) { throw new IllegalStateException( getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf")); } getContainerWrapper().getTomcatContainer().remove(contextName); // Logging action Authentication auth = SecurityContextHolder.getContext().getAuthentication(); // get username logger String name = auth.getName(); logger.info(getMessageSourceAccessor().getMessage("probe.src.log.undeploy"), name, contextName); } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.error("Error during undeploy of '{}'", contextName, e); return new ModelAndView(new InternalResourceView( getFailureViewName() == null ? getViewName() : getFailureViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName())); }
@Override public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { String contextName = ServletRequestUtils.getStringParameter(request, "context", null); if (contextName != null) { try { if (getContainerWrapper().getTomcatContainer().installContext(contextName)) { request.setAttribute("successMessage", getMessageSourceAccessor() .getMessage("probe.src.deploy.context.success", new Object[] {contextName})); // Logging action Authentication auth = SecurityContextHolder.getContext().getAuthentication(); // get username logger String name = auth.getName(); logger.info(getMessageSourceAccessor().getMessage("probe.src.log.deploycontext"), name, contextName); } else { request.setAttribute("errorMessage", getMessageSourceAccessor() .getMessage("probe.src.deploy.context.failure", new Object[] {contextName})); } } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.trace("", e); } } return new ModelAndView(new InternalResourceView(getViewName())); }
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { for (String sidWebApp : ServletRequestUtils.getStringParameters(request, "sid_webapp")) { if (sidWebApp != null) { String[] ss = sidWebApp.split(";"); if (ss.length == 2) { String sessionId = ss[0]; String appName = ss[1]; Context context = getContainerWrapper().getTomcatContainer().findContext(appName); if (context != null) { Manager manager = context.getManager(); Session session = manager.findSession(sessionId); if (session != null && session.isValid()) { session.expire(); } } else { return new ModelAndView("errors/paramerror"); } } else { return new ModelAndView("errors/paramerror"); } } } return new ModelAndView(new InternalResourceView(getViewName())); }
return new ModelAndView(new InternalResourceView(getViewName()));
return new ModelAndView(new InternalResourceView(getViewName()));
public class CustomViewResolver extends InternalResourceViewResolver { @Override public View resolveViewName(String viewName, Locale locale) throws Exception { try{ return super.resolveViewName(); } catch (Exception ex) { //log return new InternalResourceView("urlForErrorView"); } } }
@RequestMapping(value = "/test", method = RequestMethod.GET) public View myTest() { return new InternalResourceView("/WEB-INF/content/somecontent.txt"); }
@Controller public class WelcomeController { @RequestMapping("/") public View welcomeUrl() { return new InternalResourceView("index.html"); } }
request.setAttribute("errors", "example errors"); return new ModelAndView(new InternalResourceView("/login.htm"));
@Controller class MyController{ @RequestMapping(value = "/getValue") public View getValue(){ if(Response.type == "json") return new MappingJackson2JsonView(); else if(Response.type == "xml") return MarhallingView(); else return new InternalResourceView("/getValue.jsp"); } }
return new InternalResourceView(forwardUrl);
/** * Resolves a {@link View} from the provided view name. * * @param viewName must not be <code>null</code>. */ @Override public View resolveViewName(String viewName, Locale locale) { if (viewName == null) { throw new IllegalArgumentException("Method argument viewName must not be null."); } if (viewName.startsWith(REDIRECT_URL_PREFIX)) { String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length()); return new SlingRedirectView(redirectUrl, true, true); } if (viewName.startsWith(FORWARD_URL_PREFIX)) { String forwardUrl = viewName.substring(FORWARD_URL_PREFIX.length()); return new InternalResourceView(forwardUrl); } return resolveScriptingView(viewName); }
private View getViewInternal(String viewPath, RequestContext context, ApplicationContext flowContext) { if (viewPath.endsWith(".jsp") || viewPath.endsWith(".jspx")) { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(flowContext); return view; } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(flowContext); return view; } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]"); } } }
private View getViewInternal(String viewPath, RequestContext context, ApplicationContext flowContext) { if (viewPath.endsWith(".jsp") || viewPath.endsWith(".jspx")) { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(flowContext); return view; } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(flowContext); return view; } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]"); } } }