I am using Thymeleaf along with Springboot in Scala. When I do a get request from HTML page, it goes to the controller and returns the next HTML file name as a string instead of the entire HTML.
my build.gradle
compile("org.thymeleaf:thymeleaf-spring4")
compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
I have placed all html in src/main/resources/templates
main html
<html xmlns:th="http://www.thymeleaf.org">
<a href="#" th:href="@{/api/v1/users/userval}">Login</a>
Controller
@RestController
@RequestMapping(value = Array("/api/v1/users"),produces = Array("text/html"))
class UserController {
@RequestMapping(method = Array(RequestMethod.POST))
@ResponseStatus(value = HttpStatus.CREATED)
def createUser(@Valid @RequestBody user:User) = {
UserRepository.populateUser(user)
}
@RequestMapping(value=Array("/userval"),method = Array(RequestMethod.GET))
def userLoginForm( model:Model) = {
model.addAttribute("userLogin", new UserLogin())
"login"}
@RequestMapping(value=Array("/userval"),method = Array(RequestMethod.POST))
def getUser(@ModelAttribute userLogin:UserLogin, bindingResult: BindingResult) = {
"reservations"
}
Here when I click on login link in main HTML, I get "login" as a string instead of login.html