Refactor all Spring Session, Apache Geode Samples using Spring Boot to switch from Thymeleaf to FreeMarker.
Convert Thymelead templates to FreeMarker templates. Remove the use of WebJars. Refactor all Sample application code.
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.pages;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
@@ -74,7 +74,7 @@ public class Application {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleClient", logLevel = "error",
|
||||
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleClient",
|
||||
readTimeout = 15000, retryAttempts = 1, subscriptionEnabled = true) // <3>
|
||||
@EnableGemFireHttpSession(poolName = "DEFAULT") // <4>
|
||||
static class ClientCacheConfiguration extends ClientServerIntegrationTestsSupport {
|
||||
@@ -111,18 +111,18 @@ public class Application {
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/ping")
|
||||
@GetMapping(path = "/ping")
|
||||
@ResponseBody
|
||||
public String ping() {
|
||||
return PING_RESPONSE;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, path = "/session")
|
||||
public String session(HttpSession session, ModelMap modelMap,
|
||||
@PostMapping(path = "/session")
|
||||
public String session(HttpSession session, ModelMap model,
|
||||
@RequestParam(name = "attributeName", required = false) String name,
|
||||
@RequestParam(name = "attributeValue", required = false) String value) { // <7>
|
||||
|
||||
modelMap.addAttribute("sessionAttributes",
|
||||
model.addAttribute("sessionAttributes",
|
||||
attributes(setAttribute(updateRequestCount(session), name, value)));
|
||||
|
||||
return INDEX_TEMPLATE_VIEW_NAME;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<!DOCTYPE html SYSTEM "https://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-3.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Session Attributes</title>
|
||||
<style type="text/css">
|
||||
@@ -19,7 +18,7 @@
|
||||
|
||||
<h1>Try it</h1>
|
||||
|
||||
<form class="form-inline" role="form" action="./session" method="post">
|
||||
<form role="form" action="./session" method="post">
|
||||
<label for="attributeName">Attribute Name</label>
|
||||
<input id="attributeName" type="text" name="attributeName"/>
|
||||
<label for="attributeValue">Attribute Value</label>
|
||||
@@ -29,7 +28,7 @@
|
||||
|
||||
<hr/>
|
||||
|
||||
<table class="table table-striped">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attribute Name</th>
|
||||
@@ -37,10 +36,15 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="attribute: ${sessionAttributes}">
|
||||
<td th:text="${attribute.key}">name</td>
|
||||
<td th:text="${attribute.value}">value</td>
|
||||
<#attempt>
|
||||
<#list sessionAttributes as attributeName, attributeValue>
|
||||
<tr>
|
||||
<td>${attributeName}</td>
|
||||
<td>${attributeValue}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#recover>
|
||||
</#attempt>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
Reference in New Issue
Block a user