vue.jsコードを持つスプリングブートアプリケーションを開発中です。Springブートでindex.htmlにクッキーまたはヘッダーを設定する方法
初期コンテキスト "/"では、index.htmlページにCookieまたはヘッダーを設定します。
私は次のコードを試しましたが、私は404を得続けています。これを修正する方法に関するアイデアはありますか?
@Controller
public class TestController {
@RequestMapping(path = "/", method = RequestMethod.GET)
public String index(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws IOException {
String reqUrl = httpServletRequest.getRequestURL().toString();
String displayName = httpServletRequest.getHeader("displayName");
if (StringUtils.isBlank(displayName)) {
String url = "http://example.com/sso/?targetUrl=" + reqUrl;
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
System.out.println("Header from SSO" + con.getHeaderField("displayName"));
httpServletResponse.setHeader("displayName", con.getHeaderField("displayName"));
}
return "index";
}
}
これは私のプロジェクト構造の様子です。