Commit d9e326a3 authored by Dave Syer's avatar Dave Syer

Add @Value injection to JSP (WAR) sample

parent b6945564
...@@ -3,15 +3,20 @@ package org.springframework.boot.sample.jsp; ...@@ -3,15 +3,20 @@ package org.springframework.boot.sample.jsp;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@Controller @Controller
public class WelcomeController { public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/") @RequestMapping("/")
public String welcome(Map<String,Object> model) { public String welcome(Map<String,Object> model) {
model.put("time", new Date()); model.put("time", new Date());
model.put("message", message );
return "welcome"; return "welcome";
} }
......
spring.view.prefix: /WEB-INF/jsp/ spring.view.prefix: /WEB-INF/jsp/
spring.view.suffix: .jsp spring.view.suffix: .jsp
application.message: Hello Phil
\ No newline at end of file
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
Spring URL: ${springUrl} at ${time} Spring URL: ${springUrl} at ${time}
<br> <br>
JSTL URL: ${url} JSTL URL: ${url}
<br>
Message: ${message}
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment