Skip to content

Commit

Permalink
externalisation des libelles dans un fichier properties et appel à ce…
Browse files Browse the repository at this point in the history
…ux ci via @value
  • Loading branch information
hvle committed Jun 20, 2014
1 parent 6309b0a commit 15b2358
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/org/hvle/controller/HelloController.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package org.hvle.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloController {


@Value("${title}")
private String title;

@Value("${message}")
private String message;

@RequestMapping(value = { "/" }, method = RequestMethod.GET)
public ModelAndView welcomePage() {

ModelAndView model = new ModelAndView();
model.addObject("title", "Spring Security Hello World");
model.addObject("message", "This is welcome page!");
model.addObject("title", this.title);
model.addObject("message", this.message);
model.setViewName("hello");
return model;

}

}
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=Spring Security Hello World
message=This is welcome page!
1 change: 1 addition & 0 deletions src/main/webapp/WEB-INF/hvle-servlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<!-- search @Component annotation to auto instanciate -->
<context:component-scan base-package="org.hvle.*" />
<context:property-placeholder location="classpath:application.properties"/>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/"
Expand Down

0 comments on commit 15b2358

Please sign in to comment.