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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class HelloSpringApplication {

public static void main(String[] args) {
public static void main(String[] args)
{
SpringApplication.run(HelloSpringApplication.class, args);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.launchcode.hellospring.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

//added thymeleaf template
@Controller
public class HelloSpringController {

@RequestMapping(value="hello", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public String helloPost(@RequestParam String name, @RequestParam String language) {
if (name == null) {
name = "World";
}

return createMessage(name, language);

// For a bonus mission, students can change this response text to look nicer.
// This is subjective, but students should be modifying the HTML of the response string.
}

public static String createMessage(String n, String l) {
String greeting = "";

if (l.equals("english")) {
greeting = "Hello";
}
else if (l.equals("french")) {
greeting = "Bonjour";
}
else if (l.equals("italian")) {
greeting = "Bonjourno";
}
else if (l.equals("spanish")) {
greeting = "Hola";
}
else if (l.equals("german")) {
greeting = "Hallo";
}

return greeting + " " + n;
}
}
Empty file.