本文整理汇总了Java中org.springframework.web.servlet.ModelAndView.setViewName方法的典型用法代码示例。如果您正苦于以下问题:Java ModelAndView.setViewName方法的具体用法?Java ModelAndView.setViewName怎么用?Java ModelAndView.setViewName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.servlet.ModelAndView
的用法示例。
在下文中一共展示了ModelAndView.setViewName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multipleChoiceResult
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping("/multipleChoiceResult")
public ModelAndView multipleChoiceResult(ModelAndView mav, int questionNo, String answer) throws SQLException {
System.out.println("questionNo:" + questionNo);
System.out.println("answer:" + answer);
int result = questionService.checkAnswer(questionNo, answer);
boolean resultBoolean=false;
if(result!=0) resultBoolean=true;
mav.addObject("result", resultBoolean);
mav.addObject("questionNo", questionNo);
mav.addObject("multipleChoice", "multipleChoice");
mav.setViewName("/question/general/generalResult");
return mav;
}
示例2: exception
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
logger.error("Exception during execution of SpringSecurity application", throwable);
StringBuffer sb = new StringBuffer();
sb.append("Exception during execution of Spring Security application! ");
sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));
if (throwable != null && throwable.getCause() != null) {
sb.append("\n\nroot cause: ").append(throwable.getCause());
}
model.addAttribute("error", sb.toString());
ModelAndView mav = new ModelAndView();
mav.addObject("error", sb.toString());
mav.setViewName("error");
return mav;
}
示例3: defaultErrorHandler
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@ExceptionHandler(value = Exception.class)
public ModelAndView
defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
// If the exception is annotated with @ResponseStatus rethrow it and let
// the framework handle it - like the OrderNotFoundException example
// at the start of this post.
// AnnotationUtils is a Spring Framework utility class.
logger.error("exception: {}", e);
if (AnnotationUtils.findAnnotation
(e.getClass(), ResponseStatus.class) != null) {
throw e;
}
// Otherwise setup and send the user to a default error-view.
ModelAndView mav = new ModelAndView();
mav.addObject("exception", e);
mav.addObject("url", req.getRequestURL());
mav.setViewName(DEFAULT_ERROR_VIEW);
return mav;
}
示例4: exception
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
logger.error("Exception during execution of SpringSecurity application", throwable);
StringBuilder sb = new StringBuilder();
sb.append("Exception during execution of Spring Security application! ");
sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));
if (throwable != null && throwable.getCause() != null) {
sb.append(" root cause: ").append(throwable.getCause());
}
model.addAttribute("error", sb.toString());
ModelAndView mav = new ModelAndView();
mav.addObject("error", sb.toString());
mav.setViewName("error");
return mav;
}
示例5: login
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@GetMapping(value = "/login")
public ModelAndView login(
@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
logger.info("******login(error): {} ***************************************", error);
logger.info("******login(logout): {} ***************************************", logout);
ModelAndView model = new ModelAndView();
if (error != null) {
model.addObject("error", "Invalid username and password!");
}
if (logout != null) {
model.addObject("message", "You've been logged out successfully.");
}
model.setViewName("login");
return model;
}
示例6: userLogin
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping(value="/dologin.html")
public ModelAndView userLogin(@Valid User loginuser, BindingResult result){
ModelAndView mv = new ModelAndView();
// BindingResult����洢���DZ?��֤�Ľ��
if(result.hasErrors() == true){ // ��֤����
mv.setViewName("login"); // ��ת���?ҳ��
return mv;
}
// ����Service����ʵ�ֵ�¼��֤
User user = userService.login(loginuser.getUsercode(),
loginuser.getUserpassword());
//User user = null;
// ���user��Ϊnull����¼�ɹ�
if(user != null){
mv.setViewName("frame");
}else{
mv.addObject("error", "用户名或密码错误 ");
mv.setViewName("login");
}
return mv;
}
示例7: login
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login(
@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
logger.info("******login(error): {} ***************************************", error);
logger.info("******login(logout): {} ***************************************", logout);
ModelAndView model = new ModelAndView();
if (error != null) {
model.addObject("error", "Invalid username and password!");
}
if (logout != null) {
model.addObject("message", "You've been logged out successfully.");
}
model.setViewName("login");
return model;
}
示例8: shortAnswerResult
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping("/shortAnswerResult")
public ModelAndView shortAnswerResult(ModelAndView mav, int questionNo, String answer) throws SQLException {
System.out.println("questionNo:" + questionNo);
System.out.println("answer:" + answer);
int result = questionService.checkAnswer(questionNo, answer);
if (result == 1) {
mav.addObject("result", true);
} else {
mav.addObject("result", false);
}
mav.addObject("questionNo", questionNo);
mav.addObject("shortAnswer", "shortAnswer");
mav.setViewName("/question/general/generalResult");
return mav;
}
示例9: updateForm
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping("updateForm")
public ModelAndView updateForm(int courseNo, ModelAndView mav) throws Exception{
Member mvo=(Member)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Course cvo=courseService.selectMyCourse(mvo.getUserId(), courseNo);
System.out.println("cvo:"+cvo);
List<String> tags=courseService.selectCourseTag(courseNo);
System.out.println(" updateForm tags:"+tags);
mav.setViewName("course/updateCourse");
mav.addObject("cvo", cvo);
mav.addObject("tags", tags);
return mav;
}
示例10: exception
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
logger.error("Exception during execution of SpringSecurity application", throwable);
StringBuffer sb = new StringBuffer();
sb.append("Exception during execution of Spring Security application! ");
sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));
if (throwable != null && throwable.getCause() != null) {
sb.append(" root cause: ").append(throwable.getCause());
}
model.addAttribute("error", sb.toString());
ModelAndView mav = new ModelAndView();
mav.addObject("error", sb.toString());
mav.setViewName("error");
return mav;
}
示例11: managerCheckRentHouseinit
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping(value="managerCheckRentHouseinit.do", method={RequestMethod.GET,RequestMethod.POST})
public ModelAndView managerCheckRentHouseinit(HttpServletRequest request) {
ModelAndView modelAndView = new ModelAndView();
HttpSession session = request.getSession();
List<RentHouse> rentHouseList = rentHouseDao.selectAllRentHouse();
session.setAttribute("rentHouseList", rentHouseList);
modelAndView.setViewName("SystemUser/managerCheck");
return modelAndView;
}
示例12: index
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping("/")
public ModelAndView index() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findUserByEmail(auth.getName());
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("user", user);
modelAndView.setViewName("index");
return modelAndView;
}
示例13: handleUnmapped
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@ExceptionHandler(NoHandlerFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ModelAndView handleUnmapped(HttpServletRequest req) {
ModelAndView mav = new ModelAndView();
mav.addObject("page", new Page("mzTabValidator", versionNumber, gaId));
mav.addObject("error", "Resource not found!");
mav.addObject("url", req.getRequestURL());
mav.addObject("timestamp", new Date().toString());
mav.addObject("status", 404);
mav.setViewName("error");
return mav;
}
示例14: handleError
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@ExceptionHandler(Exception.class)
public ModelAndView handleError(HttpServletRequest req, Exception exception)
throws Exception {
ModelAndView mav = new ModelAndView();
mav.addObject("page", new Page("mzTabValidator", versionNumber, gaId));
mav.addObject("error", exception);
mav.addObject("url", req.getRequestURL());
mav.addObject("timestamp", new Date().toString());
mav.addObject("status", 500);
mav.setViewName("error");
return mav;
}
示例15: welcome
import org.springframework.web.servlet.ModelAndView; //导入方法依赖的package包/类
@RequestMapping("/welcome")
ModelAndView welcome(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("welcome");
modelAndView.addObject("message","Welcome to Spring Boot & Thymeleaf");
return modelAndView;
}