本文整理了Java中org.springframework.web.servlet.ModelAndView.<init>()
方法的一些代码示例,展示了ModelAndView.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ModelAndView.<init>()
方法的具体详情如下:
包路径:org.springframework.web.servlet.ModelAndView
类名称:ModelAndView
方法名:<init>
[英]Default constructor for bean-style usage: populating bean properties instead of passing in constructor arguments.
[中]bean风格用法的默认构造函数:填充bean属性,而不是传入构造函数参数。
代码示例来源:origin: spring-projects/spring-framework
/**
* Return a ModelAndView for the given view name and exception.
* <p>The default implementation adds the specified exception attribute.
* Can be overridden in subclasses.
* @param viewName the name of the error view
* @param ex the exception that got thrown during handler execution
* @return the ModelAndView instance
* @see #setExceptionAttribute
*/
protected ModelAndView getModelAndView(String viewName, Exception ex) {
ModelAndView mv = new ModelAndView(viewName);
if (this.exceptionAttribute != null) {
mv.addObject(this.exceptionAttribute, ex);
}
return mv;
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@RequestMapping("/method")
public ModelAndView method(MyEntity object) {
return new ModelAndView("/something");
}
}
代码示例来源:origin: roncoo/spring-boot-demo
/**
* 统一异常处理
*
* @param exception
* exception
* @return
*/
@ExceptionHandler({ Exception.class })
@ResponseStatus(HttpStatus.OK)
public ModelAndView processException(Exception exception) {
logger.info("自定义异常处理-Exception");
ModelAndView m = new ModelAndView();
m.addObject("roncooException", exception.getMessage());
m.setViewName("error/500");
return m;
}
代码示例来源:origin: spring-projects/spring-framework
@RequestMapping
@JsonView(MyJacksonView2.class)
public ResponseEntity<JacksonViewBean> handleResponseEntity() {
JacksonViewBean bean = new JacksonViewBean();
bean.setWithView1("with");
bean.setWithView2("with");
bean.setWithoutView("without");
ModelAndView mav = new ModelAndView(new MappingJackson2JsonView());
mav.addObject("bean", bean);
return new ResponseEntity<>(bean, HttpStatus.OK);
}
代码示例来源:origin: qcadoo/mes
@RequestMapping(value = "technologies/technologyDetailsReport.xls", method = RequestMethod.GET)
public final ModelAndView technologiesReportXls(@RequestParam("id") final String id) {
ModelAndView mav = new ModelAndView();
mav.setViewName("technologiesTechnologyDetailsXlsView");
mav.addObject("id", id);
return mav;
}
代码示例来源:origin: wuyouzhuguli/FEBS-Shiro
@ExceptionHandler(value = AuthorizationException.class)
public Object handleAuthorizationException(HttpServletRequest request) {
if (HttpUtils.isAjaxRequest(request)) {
return ResponseBo.error("暂无权限,请联系管理员!");
} else {
ModelAndView mav = new ModelAndView();
mav.setViewName("error/403");
return mav;
}
}
代码示例来源:origin: spring-projects/spring-framework
@RequestMapping("/path")
public ModelAndView methodWithHttpStatus(MyEntity object) {
return new ModelAndView("view", HttpStatus.UNPROCESSABLE_ENTITY);
}
代码示例来源:origin: timebusker/spring-boot
@RequestMapping(value = "/free0")
public ModelAndView index() {
ModelAndView mv = new ModelAndView();
mv.addObject("username", "你好!Freemarker!");
return mv;
}
代码示例来源:origin: qcadoo/mes
@RequestMapping(value = "palletNumberHelperReport.pdf")
public final ModelAndView palletNumberHelperReportPdf(@RequestParam("id") final String id) {
ModelAndView mav = new ModelAndView();
mav.setViewName("palletNumberHelperReportPdf");
mav.addObject("id", id);
return mav;
}
代码示例来源:origin: roncoo/spring-boot-demo
/**
* 统一异常处理
*
* @param exception
* exception
* @return
*/
@ExceptionHandler({ RuntimeException.class })
@ResponseStatus(HttpStatus.OK)
public ModelAndView processException(RuntimeException exception) {
logger.info("自定义异常处理-RuntimeException");
ModelAndView m = new ModelAndView();
m.addObject("roncooException", exception.getMessage());
m.setViewName("error/500");
return m;
}
代码示例来源:origin: stackoverflow.com
@ControllerAdvice
public class MyExceptionController {
@ExceptionHandler(NoHandlerFoundException.class)
public ModelAndView handleError404(HttpServletRequest request, Exception e) {
ModelAndView mav = new ModelAndView("/404");
mav.addObject("exception", e);
//mav.addObject("errorcode", "404");
return mav;
}
}
代码示例来源:origin: spring-projects/spring-framework
return new ModelAndView();
ModelAndView mav = new ModelAndView(mavContainer.getViewName(), model, status);
mav.setViewName(mavContainer.getViewName());
if (!mavContainer.isViewReference()) {
mav.setView((View) mavContainer.getView());
代码示例来源:origin: gocd/gocd
@RequestMapping(value = "/auth/login", method = RequestMethod.GET)
public Object renderLoginPage(HttpServletRequest request, HttpServletResponse response) {
if (securityIsDisabledOrAlreadyLoggedIn(request)) {
return new RedirectView("/pipelines", true);
}
response.setHeader("Cache-Control", "no-cache, must-revalidate, no-store");
response.setHeader("Pragma", "no-cache");
Map<String, Object> model = new HashMap<>();
model.put("security_auth_config_service", securityAuthConfigService);
model.put(GoVelocityView.CURRENT_GOCD_VERSION, CurrentGoCDVersion.getInstance());
return new ModelAndView("auth/login", model);
}
代码示例来源:origin: timebusker/spring-boot
@RequestMapping(value = "/free3")
public ModelAndView free3() {
ModelAndView mv3 = new ModelAndView();
Map<String, Object> map = new HashMap<String, Object>();
map.put("Java", "你好Java");
map.put("address", "北京");
map.put("身高", 172);
map.put("money", 100.5);
mv3.addObject("map", map);
return mv3;
}
代码示例来源:origin: qcadoo/mes
@RequestMapping(value = "materialRequirementCoverageReport.pdf")
public final ModelAndView materialRequirementCoverageReportPdf(@RequestParam("id") final String id) {
ModelAndView mav = new ModelAndView();
mav.setViewName("materialRequirementCoverageReportPdf");
mav.addObject("id", id);
return mav;
}
代码示例来源:origin: roncoo/spring-boot-demo
/**
* 统一异常处理
*
* @param exception
* exception
* @return
*/
@ExceptionHandler({ RuntimeException.class })
@ResponseStatus(HttpStatus.OK)
public ModelAndView processException(RuntimeException exception) {
logger.info("自定义异常处理-RuntimeException");
ModelAndView m = new ModelAndView();
m.addObject("roncooException", exception.getMessage());
m.setViewName("error/500");
return m;
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Return a ModelAndView for the given view name and exception.
* <p>The default implementation adds the specified exception attribute.
* Can be overridden in subclasses.
* @param viewName the name of the error view
* @param ex the exception that got thrown during handler execution
* @return the ModelAndView instance
* @see #setExceptionAttribute
*/
protected ModelAndView getModelAndView(String viewName, Exception ex) {
ModelAndView mv = new ModelAndView(viewName);
if (this.exceptionAttribute != null) {
mv.addObject(this.exceptionAttribute, ex);
}
return mv;
}
代码示例来源:origin: spring-projects/spring-framework
ModelAndView modelAndView = new ModelAndView();
modelAndView.addAllObjects(RequestContextUtils.getInputFlashMap(request));
if (viewName != null) {
modelAndView.setViewName(viewName);
代码示例来源:origin: spring-projects/spring-security-oauth
@RequestMapping("/oauth/confirm_access")
public ModelAndView getAccessConfirmation(Map<String, Object> model, HttpServletRequest request) throws Exception {
final String approvalContent = createTemplate(model, request);
if (request.getAttribute("_csrf") != null) {
model.put("_csrf", request.getAttribute("_csrf"));
}
View approvalView = new View() {
@Override
public String getContentType() {
return "text/html";
}
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setContentType(getContentType());
response.getWriter().append(approvalContent);
}
};
return new ModelAndView(approvalView, model);
}
代码示例来源:origin: timebusker/spring-boot
@RequestMapping("/free2")
public ModelAndView free2() {
ModelAndView mv2 = new ModelAndView();
List<String> list = new ArrayList<String>();
list.add("java");
list.add("JavaScript");
list.add("python");
list.add("php");
list.add("Html");
mv2.addObject("programList", list);
return mv2;
}
内容来源于网络,如有侵权,请联系作者删除!