Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

HTTP Status 403 - Expected CSRF token not found. Has your session expired? #63

Open
cleverlzc opened this issue Sep 16, 2017 · 0 comments

Comments

@cleverlzc
Copy link

My problem was different with "HTTP Status 403 - Expected CSRF token not found #29" at "#29".

When I send post request to access the URL with Java CloseableHttpClient, I get the result as fllowing.

<html><head><title>Apache Tomcat/7.0.47 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 403 - Expected CSRF token not found. Has your session expired?</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Expected CSRF token not found. Has your session expired?</u></p><p><b>description</b> <u>Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.47</h3></body></html>

The main codes as fllowing:

String url  = "http://127.0.0.1:9123/spring-mvc-showcase/data/body";

//配置请求参数
		RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(2000).setConnectTimeout(2000).setSocketTimeout(2000).build();
		//创建自定义的httpClient实例
		CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
		//创建httpPost
		HttpPost post = new HttpPost(url);

CloseableHttpResponse response = httpClient.execute(post);
			HttpEntity respEntity = response.getEntity();

But, when I sent get request, it can work rightly.

Why this error?
What shoud I do to solve this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant