,这两个我都尝试了,不会将下面图的中的参数放到请求中。如果直接添加到
HttpHeaders headers = new HttpHeaders();
headers.add("Cookie","SESSION="+request.getSession().getId()+"; path=/; domain=172.28.120.168; HttpOnly;");
或者将后面的; path=/; domain=172.28.120.168; HttpOnly;全部或者单个删掉,都显示登录失败。
求教如何添加这个session属性[/quote]
这样就能添加header了[/quote]
header里面添加的跟您写的应该是一致的,我是这样写的
然后我尝试了下在postman中,将Cookie中的数据添加到header中,也登录成功了,
但是出现了跟中午的时候一样的问题:
<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Fri Feb 26 14:31:49 CST 2021</div><div>There was an unexpected error (type=Internal Server Error, status=500).</div><div>PreparedStatementCallback; SQL [INSERT INTO SPRING_SESSION_ATTRIBUTES(SESSION_ID, ATTRIBUTE_NAME, ATTRIBUTE_BYTES) VALUES (?, ?, ?)]; Cannot add or update a child row: a foreign key constraint fails (`ceair_test`.`spring_session_attributes`, CONSTRAINT `spring_session_attributes_ibfk_1` FOREIGN KEY (`SESSION_ID`) REFERENCES `spring_session` (`SESSION_ID`) ON DELETE CASCADE); nested exception is java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`ceair_test`.`spring_session_attributes`, CONSTRAINT `spring_session_attributes_ibfk_1` FOREIGN KEY (`SESSION_ID`) REFERENCES `spring_session` (`SESSION_ID`) ON DELETE CASCADE)</div></body></html>
今天尝试重写HttpURLConnection,将cookie信息.setRequestProperty("cookie", "SESSION="+request.getSession().getId()+"; domain=127.0.0.1; path:/;HttpOnly=true;");虽然同样登录不成功,但是页面开始报这个错误:
<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Fri Feb 26 14:31:49 CST 2021</div><div>There was an unexpected error (type=Internal Server Error, status=500).</div><div>PreparedStatementCallback; SQL [INSERT INTO SPRING_SESSION_ATTRIBUTES(SESSION_ID, ATTRIBUTE_NAME, ATTRIBUTE_BYTES) VALUES (?, ?, ?)]; Cannot add or update a child row: a foreign key constraint fails (`ceair_test`.`spring_session_attributes`, CONSTRAINT `spring_session_attributes_ibfk_1` FOREIGN KEY (`SESSION_ID`) REFERENCES `spring_session` (`SESSION_ID`) ON DELETE CASCADE); nested exception is java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`ceair_test`.`spring_session_attributes`, CONSTRAINT `spring_session_attributes_ibfk_1` FOREIGN KEY (`SESSION_ID`) REFERENCES `spring_session` (`SESSION_ID`) ON DELETE CASCADE)</div></body></html>