Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: java

notifications:
email:
recipients:
- dmunnoz96@gmail.com
on_success: always # default: change
on_failure: always # default: always

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# hello-java
This is just a hello world example for the students of EGC course

[![Build Status](https://travis-ci.org/DominMuda/hello-java.svg?branch=add-languages)](https://travis-ci.org/DominMuda/hello-java)
2 changes: 1 addition & 1 deletion src/main/java/hello/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}
}
8 changes: 5 additions & 3 deletions src/main/java/hello/GreetingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
@Controller
public class GreetingController {

private GreetingTranslator greetingTranslator;

@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name,
Model model) {
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name,@RequestParam(value="lang", required=false, defaultValue="en") String lang, Model model) {
model.addAttribute("hello", greetingTranslator.sayHelloIn(lang));
model.addAttribute("name", name);
return "greeting";
}

}
}
17 changes: 17 additions & 0 deletions src/main/java/hello/GreetingTranslator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package hello;

public class GreetingTranslator {

public String sayHelloIn(String lang) {
String hello;
if ("en".equals(lang)) {
hello = "hello";
} else if ("es".equals(lang)) {
hello = "hola";
} else {
hello = "no hablo tu idioma";
}
return hello;
}

}
2 changes: 1 addition & 1 deletion src/main/resources/templates/greeting.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
</body>
</html>
</html>