在主配置文件中:
#配置视图解析器
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp
如图:
在控制器类(处理器类)中:
这两种方法都是一样的,返回视图
package com.hujin.springboottest01.controller;
import com.hujin.springboottest01.cofig.School;
import com.hujin.springboottest01.cofig.baidu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class MyController {
@RequestMapping("/mycontroller")
public ModelAndView test(){
ModelAndView mv=new ModelAndView();
mv.addObject("msg","进入了index.jsp");