gpt4 book ai didi

java - 如何使用POST方法代替GET方法

转载 作者:行者123 更新时间:2023-12-02 08:59:01 31 4
gpt4 key购买 nike

我使用了POST方法,但出现以下错误。最后一行显示错误。最初,我没有使用SecurityConfiguration。现在,我正在使用SecurityConfiguration允许所有操作,并且仍然收到身份验证错误。

public class SecurityConfiguration extends WebSecurityConfigurerAdapter{

public void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.authorizeRequests().antMatchers("/").permitAll();
}
}


[2020-02-19 16:02:59.357] [DEBUG] [Context:FilterSecurityInterceptor] [] [先前已认证:org.springframework.security.authentication.AnonymousAuthenticationToken@64bc4ef4:委托人:onymousUser;凭证:[受保护];已验证:true;详细信息:org.springframework.security.web.authentication.WebAuthenticationDetails@380f4:RemoteIpAddress:0:0:0:0:0:0:0:1; SessionId:53EB7CECE3D38AF3B70968DB6125DA86;授予的权限:ROLE_ANONYMOUS]
[2020-02-19 16:02:59.368] [DEBUG] [Context:AffirmativeBased] [] [投票人:org.springframework.security.web.access.expression.WebExpressionVoter@1173b3b2,返回:-1]
[2020-02-19 16:02:59.371] [DEBUG] [Context:ExceptionTranslationFilter] [] [访问被拒绝(用户是匿名的);重定向到身份验证入口点]
org.springframework.security.access.AccessDeniedException:访问被拒绝
    在org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:84)
    在org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:233)上
    在org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:123)
    在org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:216)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)处
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
    在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    在org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
    在org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
    在org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
    在org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
    在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    在org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
    在org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
    在org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    在org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    在org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:394)
    在org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:253)
    在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175)
    在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
    在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:860)
    在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1591)
    在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)
    在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)
    在java.lang.Thread.run(Thread.java:748)
[2020-02-19 16:02:59.385] [DEBUG] [Context:AndRequestMatcher] [] [尝试使用Ant [pattern ='/',GET]进行匹配]
** [2020-02-19 16:02:59.386] [DEBUG] [Context:AntPathRequestMatcher] [] [请求'POST / error'与'GET /'不匹配” **


@PostMapping(value ="/createAncillaries")
public CreateOrderResponseType createAncillaries(@RequestBody(required=true) String message ) {
return orderDetailsService.createAncillaries(message);
}

最佳答案

URL有长度限制。检查此-https://stackoverflow.com/a/417184/919158

尝试使用POST方法并将数据发布为@RequestBody

关于java - 如何使用POST方法代替GET方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60308376/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com