spring boot Thymeleaf

spring boot Thymeleaf,第1张

spring boot Thymeleaf

spring initializr构建项目
依赖


            org.springframework.boot
            spring-boot-starter-thymeleaf
        

success.html




    
    Title


 哈
去百度
去百度1


@Controller
public class viewController {
    @GetMapping("/atguigu")
    public String atguigu(Model model){
        model.addAttribute("msg","你好 guigu");
        model.addAttribute("link","http://www.baidu.com");

        return "success";
    }
}




    
    Title


 哈
去百度
去百度1


增加以下代码

@GetMapping("/s")
    public String s(Model model){
        return "s";
    }

s.html




    
    Title


uigvuiwygbwiuvwhiugbvrioubuwibhgvpu3igvbiu


点击去百度1,跳转到s.html页面

application.properties添加这段

server.servlet.context-path=/world

%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>




    
    Insert title here





@GetMapping("/cll.jsp")
    public String dfg(){
        return "s";
    }

仍然显示s.html内容

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5712841.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存