Add JSTL to JSP sample

pull/138/head
Dave Syer 11 years ago
parent f4f668a52b
commit 3f1cfbf241

@ -211,16 +211,6 @@
<enabled>false</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
</repository> </repository>
<repository>
<id>gradle</id>
<url>http://repo.gradle.org/gradle/libs-releases-local</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories> </repositories>
<build> <build>
<pluginManagement> <pluginManagement>

@ -22,6 +22,10 @@
<groupId>org.apache.tomcat.embed</groupId> <groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId> <artifactId>tomcat-embed-jasper</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

@ -1,5 +1,8 @@
package org.springframework.boot.sample.jsp; package org.springframework.boot.sample.jsp;
import java.util.Date;
import java.util.Map;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -7,7 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class WelcomeController { public class WelcomeController {
@RequestMapping("/") @RequestMapping("/")
public String welcome() { public String welcome(Map<String,Object> model) {
model.put("time", new Date());
return "welcome"; return "welcome";
} }

@ -1,12 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html lang="en"> <html lang="en">
<body> <body>
<c:url value="/resources/text.txt" var="url"/>
<spring:url value="/resources/text.txt" htmlEscape="true" var="springUrl" /> <spring:url value="/resources/text.txt" htmlEscape="true" var="springUrl" />
${springUrl} Spring URL: ${springUrl} at ${time}
<br>
JSTL URL: ${url}
</body> </body>
</html> </html>

@ -68,4 +68,16 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>gradle</id>
<url>http://repo.gradle.org/gradle/libs-releases-local</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project> </project>

Loading…
Cancel
Save