Add JSTL to JSP sample
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package org.springframework.boot.sample.jsp;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@@ -7,7 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
public class WelcomeController {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String welcome() {
|
||||
public String welcome(Map<String,Object> model) {
|
||||
model.put("time", new Date());
|
||||
return "welcome";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<body>
|
||||
<c:url value="/resources/text.txt" var="url"/>
|
||||
<spring:url value="/resources/text.txt" htmlEscape="true" var="springUrl" />
|
||||
${springUrl}
|
||||
Spring URL: ${springUrl} at ${time}
|
||||
<br>
|
||||
JSTL URL: ${url}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user