Skip to content
Open

tds #17

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: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
language: java
jdk: oraclejdk8
jdk: oraclejdk8
services:
- mysql

before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS hello_test;'
env:
- DATABASE=jdbc:mysql://localhost:3306/hello_test DB_USERNAME=travis DB_PASSWORD=""
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java -jar target/dependency/jetty-runner.jar --port $PORT target/hello-java-0.1.0.war
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# hello-java
This is just a hello world example for the students of EGC course
[![Build Status](https://travis-ci.org/josromada/hello-java.svg?branch=master)](https://travis-ci.org/josromada/hello-java)
26 changes: 25 additions & 1 deletion src/main/resources/templates/greeting.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,28 @@
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
</body>
</html>
</html>
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";
}
}

}
@RequestMapping("/greeting")
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";
}