当前位置: 首页>>代码示例>>Java>>正文


Java ModelAndView.setViewName方法代码示例

本文整理汇总了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;
}
 
开发者ID:INSUPARK83,项目名称:way_learning,代码行数:17,代码来源:GeneralQuestionController.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:21,代码来源:ErrorController.java

示例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;
}
 
开发者ID:sinaa,项目名称:train-simulator,代码行数:21,代码来源:GlobalDefaultExceptionHandler.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:21,代码来源:ErrorController.java

示例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;

}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:22,代码来源:LoginController.java

示例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;
}
 
开发者ID:Marui0325,项目名称:y2t187test,代码行数:25,代码来源:UserControl.java

示例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;

}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:22,代码来源:LoginController.java

示例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;
}
 
开发者ID:INSUPARK83,项目名称:way_learning,代码行数:19,代码来源:GeneralQuestionController.java

示例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;

}
 
开发者ID:INSUPARK83,项目名称:way_learning,代码行数:18,代码来源:CourseController.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:21,代码来源:ErrorController.java

示例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;
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:12,代码来源:AdminInit.java

示例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;
}
 
开发者ID:garydamm,项目名称:idea-forge,代码行数:10,代码来源:IndexController.java

示例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;
}
 
开发者ID:nilshoffmann,项目名称:jmzTab-m,代码行数:13,代码来源:ValidationController.java

示例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;
}
 
开发者ID:nilshoffmann,项目名称:jmzTab-m,代码行数:13,代码来源:ValidationController.java

示例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;
}
 
开发者ID:ken-io,项目名称:springboot-course,代码行数:8,代码来源:HelloController.java


注:本文中的org.springframework.web.servlet.ModelAndView.setViewName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。