0
点赞
收藏
分享

微信扫一扫

SpringBoot·Jsp视图

肉肉七七 2022-04-03 阅读 33

SpringBoot·Jsp视图

创建指定jsp的web目录

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

配置视图存放的文件位置

server.port=9098
server.context-path=/teach02
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
logging.level.com.debug.steadyjack=debug

#数据源配置
datasource.url=jdbc:mysql://127.0.0.1:3306/db_springboot_teach_02?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
datasource.username=root
datasource.password=linsen
datasource.druid.pool.initialSize=10

mybatis.type-aliases-package=com.debug.steadyjack.entity
mybatis.mapper-locations=classpath:mappers/*.xml

#视图解析器
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp

查询jsp视图

// 视图控制层
@Controller
public class StudentPage {

    @Autowired
    private StudentMapper studentMapper;

    @RequestMapping(value = "/index",method= RequestMethod.GET)
    public String sst(){
        return "jsp的文件名";
    }

    @RequestMapping(value =  "/index3",method = RequestMethod.GET)
    public String index3(Integer id,ModelMap modelMap)
    {
        Student student = studentMapper.selectByPrimaryKey(id);
        modelMap.addAttribute("student",student);
        return "jsp的文件名" ;
    }
}
举报

相关推荐

0 条评论