So I am trying to follow this guide on how to serve html files with Spring: http://ift.tt/1gY8lwn
I have the exact same folder structure with exact same files but when I run the spring boot server, my localhost:8080/greeting will only show the string greeting that is returned from the GreetingController and that's it, if I look at the page source code, there is no html in it.
I could not find any related answers about this because all the similar answers still use the .xml file driven Spring where you declare the views in a .xml file. But this guide explicitly says that no .xml needs to be used. It should just work like that.
Mapping:
@RestController
public class GreetingController {
@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name", required = false, defaultValue="World") String name, Model model) {
model.addAttribute("name", name);
return "greeting";
}
}
Aucun commentaire:
Enregistrer un commentaire