我的结构
WEB-INF
??? thymeleaf
??? fragments
? ??? head.html
??? index
? ??? index.html
??? layout.html
Run Code Online (Sandbox Code Playgroud)
layout.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:insert="~{fragments/head :: head}" th:remove="tag"></head>
<body>
<!--${view} == "index/index"-->
<div th:insert="~{${view} :: content}" th:remove="tag"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
index.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title id="pageTitle">My Title with ID</title>
</head>
<body>
<div th:fragment="title">My Title With fragment</div>
<div th:fragment="content">
My page
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
head.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head" th:remove="tag">
<meta charset="utf-8">
<title>??????</title>
<link href="/css/bootstrap.css" rel="stylesheet">
</head>
<body>
</body>
</html> …Run Code Online (Sandbox Code Playgroud) 我被指定对一个项目进行重构,我遇到了这种情况
this.path = DESTINY + deploy.name() + FILE_SEPARATOR + delivery.getSystem().getCode()
+ FILE_SEPARATOR + delivery.getName() + FILE_SEPARATOR + delivery.getEnviroment().getName();
Run Code Online (Sandbox Code Playgroud)
我想将它重构为这样的:
StringBuilder tmpPath = new StringBuilder();
tmpPath.append(DESTINY);
tmpPath.append(deploy.name());
tmpPath.append(FILE_SEPARATOR);
tmpPath.append(delivery.getSystem().getCode());
tmpPath.append(FILE_SEPARATOR);
tmpPath.append(delivery.getName());
tmpPath.append(FILE_SEPARATOR);
tmpPath.append(delivery.getEnviroment().getName());
this.path = tmpPath.toString();
Run Code Online (Sandbox Code Playgroud)
或者
StringBuilder path = new StringBuilder();
...
this.path.append(DESTINY);
this.path.append(deploy.name());
this.path.append(FILE_SEPARATOR);
this.path.append(delivery.getSystem().getCode());
this.path.append(FILE_SEPARATOR);
this.path.append(delivery.getName());
this.path.append(FILE_SEPARATOR);
this.path.append(delivery.getEnviroment().getName());
Run Code Online (Sandbox Code Playgroud)
最快的方法是什么?