我正在使用此库thymeleaf-layout-dialect
我的布局方言......
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title layout:title-pattern="$DECORATOR_TITLE - $CONTENT_TITLE">NextInfo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../../../resources/css/animate.css" th:href="@{'resources/css/animate.css'}"/>
<link rel="stylesheet" type="text/css" href="../../../resources/css/semantic.min.css" th:href="@{'resources/css/semantic.min.css'}"/>
</head>
<body>
<div class="ui stackable blue inverted menu">
<a class="right item ">
<i class="home icon"></i>
Inicio
</a>
<a class="item">
<i class="phone icon"></i>
Telefones
</a>
<a class="item">
<i class="mail Outline icon"></i>
Email
</a>
<a class="item">
<i class="chat icon"></i>
Suporte
</a>
<div class="ui category search item" style="margin-right:40px">
<div class="ui transparent icon input">
<input class="prompt" type="text" placeholder=" pesquisar ..." />
<i class="search link icon"></i>
</div>
<div class="results"></div>
</div>
</div>
<div id="header" layout:fragment="header"></div>
<div id="content" layout:fragment="content"></div>
<div id="footer" layout:fragment="footer"></div>
<script src="../../../resources/js/jquery.min.js" data-th-src="@{resources/js/jquery.min.js}"></script>
<script src="../../../resources/js/semantic.min.js" data-th-src="@{resources/js/semantic.min.js}"></script>
</body>
</html>
我创建了一个布局,如链接
所示我的家庭控制器
@Controller
@RequestMapping(value ={"/","/home"})
public class Principal {
private final static String URLINICIAL = "index";
@RequestMapping(value ={"/","/home"} ,method=RequestMethod.GET)
public String requisicaoPadrao() {
return URLINICIAL;
}
@ResponseBody
@RequestMapping(value = "/testes", method=RequestMethod.GET)
public <T> Object testes() {
return null;
}
}
的index.html
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="/templates/layouts/default">
<head>
</head>
<body>
<div layout:fragment="header"><h1>index</h1></div>
<div layout:fragment="content"></div>
</body>
</html>
创建新视图
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="/templates/layouts/default">
<head>
<title>testPage</title>
</head>
<body>
<h1>teste</h1>
<div layout:fragment="header"><h1>testPage</h1></div>
<div layout:fragment="content"></div>
</body>
</html>
新控制器
我需要在课程上方添加@RequestMapping注释。
@Controller
@RequestMapping("/test")
public class TestController {
@RequestMapping(value = "/", method=RequestMethod.GET)
public String index(){
return "testpage";
}
}
你可以看到它不起作用.... 怎么解决?
答案 0 :(得分:1)
我设法通过更改此<script src="../../../resources/js/jquery.min.js" data-th-src="@{resources/js/jquery.min.js}"></script>
的
<script src="/web/resources/js/lib/jquery.min.js"></script>
我没有使用特定标签thymeleaf