|
|
@@ -3,14 +3,11 @@ package cc.javastudio; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.ui.Model; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import static org.springframework.web.bind.annotation.RequestMethod.GET; |
|
|
|
import static org.springframework.web.bind.annotation.RequestMethod.POST; |
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
@@ -19,7 +16,13 @@ public class HelloController { |
|
|
|
|
|
|
|
@GetMapping |
|
|
|
public String printHello(@RequestParam(defaultValue = "Hi") String greeting, @RequestParam(defaultValue = "There") List<String> name, Model model) { |
|
|
|
model.addAttribute("title", greeting + " " +name); |
|
|
|
String separator = " & "; |
|
|
|
String names = ""; |
|
|
|
for (String element:name) { |
|
|
|
names += element + separator; |
|
|
|
} |
|
|
|
names = names.substring(0,names.length()-separator.length()); |
|
|
|
model.addAttribute("title", greeting + " " +names); |
|
|
|
model.addAttribute("date", new java.util.Date()); |
|
|
|
return "hello"; |
|
|
|
} |