提交 0d3ca034 authored 作者: huangxingyao's avatar huangxingyao

上级 2c85bbbb
...@@ -13,6 +13,7 @@ import org.springframework.web.client.HttpClientErrorException; ...@@ -13,6 +13,7 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -25,11 +26,7 @@ public class ProductPageController { ...@@ -25,11 +26,7 @@ public class ProductPageController {
@Autowired @Autowired
private RatingsClient ratingsClient; private RatingsClient ratingsClient;
@GetMapping("/")
public String getIndex(Model model) {
model.addAttribute("name", "hello world");
return "index";
}
@GetMapping("/health") @GetMapping("/health")
public String health(){ public String health(){
return "Product page is healthy"; return "Product page is healthy";
...@@ -37,17 +34,16 @@ public class ProductPageController { ...@@ -37,17 +34,16 @@ public class ProductPageController {
@PostMapping("/login") @PostMapping("/login")
public String login(@RequestParam(name = "username", required = true) String username, public String login(@RequestParam(name = "username", required = true) String username,
HttpServletRequest request){ HttpServletRequest request, HttpServletResponse response){
String user = username; String user = username;
request.getSession().setAttribute("user", user); request.getSession().setAttribute("user", user);
return "productpage"; response.setHeader("end-user",user);
//return "redirect:/productpage"; return "redirect:productpage";
} }
@GetMapping("/logout") @GetMapping("/logout")
public String destroySession(HttpServletRequest request) { public String destroySession(HttpServletRequest request) {
request.getSession().invalidate(); request.getSession().invalidate();
return "productpage"; return "redirect:productpage";
//return "redirect:/productpage";
} }
@GetMapping("/productpage") @GetMapping("/productpage")
......
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
</body>
</html>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论