user20236531
user20236531

Reputation: 1

how springboot return html rendered rather than literal?

@Controller
@RequestMapping("/member")
public class OAuthController {


@ResponseBody
@GetMapping("/name")
public String abcCallback(@RequestParam String code,Model model){ 
abc=service.getname(code);
model.addAttribute("abc",abc);

return "/main.html";
}

}

i omit extra. i want to return model to main.html [located in src/main/resources/templates/main.html] but when i run this. it shows literally /main.html should i change my annotation? i'm confusing

change return "main.html", return "main" change annotation @restController

but doesn't work

Upvotes: 0

Views: 94

Answers (1)

Girija Sankar Panda
Girija Sankar Panda

Reputation: 318

@RestController is having both @Controller and @ResponseBody . The issue here is @ResponseBody which needs to be removed.

@Controller
@RequestMapping("/member")
public class OAuthController {



@GetMapping("/name")
public String abcCallback(@RequestParam String code,Model model){ 
abc=service.getname(code);
model.addAttribute("abc",abc);

return "main";
}

}

Upvotes: 1

Related Questions