use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class ParameterizableViewControllerTests method viewName.
@Test
public void viewName() throws Exception {
this.controller.setViewName("view");
ModelAndView modelAndView = this.controller.handleRequest(this.context);
assertThat(modelAndView.getViewName()).isEqualTo("view");
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class ParameterizableViewControllerTests method handleRequestHttpOptions.
@Test
public void handleRequestHttpOptions() throws Exception {
this.request.setMethod(HttpMethod.OPTIONS.name());
ModelAndView mav = this.controller.handleRequest(this.context);
assertThat(mav).isNull();
assertThat(response.getHeader("Allow")).isEqualTo("GET,HEAD,OPTIONS");
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class AbstractUrlViewController method handleRequestInternal.
/**
* Retrieves the URL path to use for lookup and delegates to
* {@link #getViewNameForRequest}. Also adds the content of
* {@link RequestContextUtils#getInputRedirectModel(RequestContext)} to the model.
*/
@Override
protected ModelAndView handleRequestInternal(RequestContext request) {
String viewName = getViewNameForRequest(request);
if (log.isTraceEnabled()) {
log.trace("Returning view name '{}'", viewName);
}
RedirectModel model = RequestContextUtils.getInputRedirectModel(request);
if (model != null) {
return new ModelAndView(viewName, model.asMap());
}
return new ModelAndView(viewName);
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class ModelAndViewReturnValueHandler method handleModelAndView.
/**
* Resolve {@link ModelAndView} return type
*
* @since 2.3.3
*/
public final void handleModelAndView(RequestContext context, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
if (modelAndView != null) {
View view = modelAndView.getView();
String viewName = modelAndView.getViewName();
BindingContext bindingContext = context.getBindingContext();
bindingContext.addAllAttributes(modelAndView.getModel());
if (viewName != null) {
delegate.renderView(context, viewName);
} else if (view != null) {
delegate.renderView(context, view);
}
}
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class VoidReturnValueHandler method handleReturnValue.
/**
* mainly for ModelAndView
*
* @param context Current HTTP request context
* @param handler Target HTTP handler
* @param returnValue Handler execution result
* Or {@link HandlerExceptionHandler} return value
*/
@Override
public void handleReturnValue(RequestContext context, Object handler, @Nullable Object returnValue) throws Exception {
BindingContext bindingContext = context.getBindingContext();
if (bindingContext.hasModelAndView()) {
ModelAndView modelAndView = bindingContext.getModelAndView();
// user constructed a ModelAndView hold in context
returnValueHandler.handleModelAndView(context, null, modelAndView);
}
}
Aggregations