当前位置: 首页 > 知识库问答 >
问题:

Spring MVC-基于注释的控制器找不到请求处理程序方法

易淳
2023-03-14

在我添加了一个Spring Security过滤器后,这就停止工作了。

部署应用程序时,映射按预期配置

INFO annotation.RequestMappingHandlerMapping: Mapped "{[/countries],methods=[GET],params=[!countryCode],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public com.purpleleaf.proxy.rest.data.ProxyResponse com.purpleleaf.proxy.rest.service.reference.DefaultCountry.findAll()

提交GET请求。

GET http://localhost:8081/purpleleaf-admin-1.0.0/countries?page=1&start=0&limit=25

请求参数是由ExtJS添加的,这不是一个问题,因为它在没有安全性的情况下工作。

DEBUG util.AntPathRequestMatcher: Checking match of request : '/countries'; against '/*'
DEBUG web.FilterChainProxy: /countries?page=1&start=0&limit=25 has an empty filter list
DEBUG servlet.DispatcherServlet: DispatcherServlet with name 'admin-spring' processing GET request for [//purpleleaf-admin-1.0.0/countries]
DEBUG annotation.RequestMappingHandlerMapping: Looking up handler method for path //purpleleaf-admin-1.0.0/countries
DEBUG annotation.RequestMappingHandlerMapping: Did not find handler method for [//purpleleaf-admin-1.0.0/countries]
DEBUG handler.SimpleUrlHandlerMapping: Matching patterns for request [//purpleleaf-admin-1.0.0/countries] are [/**]
DEBUG handler.SimpleUrlHandlerMapping: URI Template variables for request [//purpleleaf-admin-1.0.0/countries] are {}
DEBUG handler.SimpleUrlHandlerMapping: Mapping [//purpleleaf-admin-1.0.0/countries] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler@3f8050cf] and 1 interceptor
DEBUG servlet.DispatcherServlet: Last-Modified value for [//purpleleaf-admin-1.0.0/countries] is: -1
DEBUG servlet.DispatcherServlet: Null ModelAndView returned to DispatcherServlet with name 'admin-spring': assuming HandlerAdapter completed request handling
DEBUG servlet.DispatcherServlet: Successfully completed request
<servlet-mapping>
    <servlet-name>admin-spring</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
   xmlns:beans="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
    <beans:import resource="classpath*:applicationContext-CrowdClient.xml" />

<beans:bean id="crowdUserDetailsService" class="com.atlassian.crowd.integration.springsecurity.user.CrowdUserDetailsServiceImpl">
    <beans:property name="authenticationManager" ref="crowdAuthenticationManager"/>
    <beans:property name="groupMembershipManager" ref="crowdGroupMembershipManager"/>
    <beans:property name="userManager" ref="crowdUserManager"/>
    <beans:property name="authorityPrefix" value="ROLE_"/>
</beans:bean>

<beans:bean id="crowdAuthenticationProvider" class="com.atlassian.crowd.integration.springsecurity.RemoteCrowdAuthenticationProvider">
    <beans:constructor-arg ref="crowdAuthenticationManager"/>
    <beans:constructor-arg ref="httpAuthenticator"/>
    <beans:constructor-arg ref="crowdUserDetailsService"/>
</beans:bean>

<authentication-manager alias="authenticationManager">
    <authentication-provider ref='crowdAuthenticationProvider' />
</authentication-manager>

<beans:bean id="crowdAuthenticationProcessingFilterEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
    <beans:constructor-arg value="/login.jsp" />
</beans:bean>

<beans:bean id="crowdAuthenticationProcessingFilter" class="com.atlassian.crowd.integration.springsecurity.CrowdSSOAuthenticationProcessingFilter">
    <beans:property name="httpAuthenticator" ref="httpAuthenticator"/>
    <beans:property name="authenticationManager" ref="authenticationManager"/>
    <beans:property name="filterProcessesUrl" value="/j_security_check"/>
    <beans:property name="authenticationFailureHandler">
        <beans:bean class="com.atlassian.crowd.integration.springsecurity.UsernameStoringAuthenticationFailureHandler">
            <beans:property name="defaultFailureUrl" value="/login.jsp?error=true"/>
        </beans:bean>
    </beans:property>

    <beans:property name="authenticationSuccessHandler">
        <beans:bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
            <beans:property name="defaultTargetUrl" value="/"/>
        </beans:bean>
    </beans:property>
</beans:bean>

<beans:bean id="crowdLogoutHandler" class="com.atlassian.crowd.integration.springsecurity.CrowdLogoutHandler">
    <beans:property name="httpAuthenticator" ref="httpAuthenticator"/>
</beans:bean>
<beans:bean id="securityContextLogoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />

<beans:bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
    <beans:constructor-arg index="0" value="/index.html"/>
    <beans:constructor-arg index="1">
        <beans:list>
            <beans:ref bean="crowdLogoutHandler"/>
            <beans:ref bean="securityContextLogoutHandler"/>
        </beans:list>
    </beans:constructor-arg>
    <beans:property name="filterProcessesUrl" value="/logout.html"/>
</beans:bean>

<http pattern='/*' security='none'/>
<!--http pattern='/scripts/*' security='none'/-->

<http auto-config="false" entry-point-ref="crowdAuthenticationProcessingFilterEntryPoint">

    <custom-filter position="FORM_LOGIN_FILTER" ref='crowdAuthenticationProcessingFilter'/>
    <custom-filter position="LOGOUT_FILTER" ref='logoutFilter'/>

    <!--intercept-url pattern="/admin/*" access="ROLE_application-administrators"/-->
    <!--intercept-url pattern="/passwordHint.html" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/-->
    <!--security:intercept-url pattern="/**/*.html*" access="IS_AUTHENTICATED_FULLY"/-->
</http>
</beans:beans>

共有1个答案

章博耘
2023-03-14

根本原因是URL上的purpleleaf-admin-1.0.0。Util.AntPathRequestMatcher在包含点(.)时无法正确解析路径。

在添加安全筛选器之前,该类不在路径中。

 类似资料:
  • 问题内容: 我正在尝试使用插入文档api的自动增量id功能向我的elasticsearch索引发出原始NodeJS http请求。 所以这适用于: 但是当我通过以下方式在nodejs中尝试相同的操作时: 它返回此错误: 但是,如果我在该路径的末尾添加一个,它将起作用。怎么了 问题答案: 这里的问题是方式和工作方式,当您使用时,它是可选的,ES 每次都会为您生成一个唯一的。 在这里,您使用的是这样的

  • 我的Spring Boot应用程序中有一系列Rest API控制器,其请求映射与某些URL匹配。我需要更改我的实现,以始终确保为所有请求设置特定的自定义标头。如果标头不在那里,我想使请求失败。如果是这样,我想转发到适当的控制器,这将与我当前的实现相同。 有没有办法在Spring Boot做到这一点,而无需修改我现有的控制器呢?我可以尝试使用类似Spring Security的东西吗,即使我的头与安

  • 问题内容: 我是python的新手。我尝试登录python,但遇到尝试通过记录器实例打印一些警告时 找不到记录器 错误的 处理程序 。下面是我尝试的代码 我收到此错误, 找不到记录程序“ logger”的处理程序 令我感到困惑的是,当我第一次尝试使用,然后通过来打印警告时,它可以正常工作,例如 有人可以阐明第二种情况下发生的事情吗? 问题答案: 为了通过记录一些消息,在Python中至少应将一个处

  • 我正在使用Spring MVC 4.1为restful Web服务添加速率限制。 我创建了一个注释,可以应用于控制器方法。Spring AOP方面会拦截对这些方法的调用,并在请求过多时引发异常: 这一切都非常有效,除非控制器方法的参数标记为,例如: 问题:如果验证失败,验证器会抛出由@ExceptionHandler处理的,它会向客户端返回错误响应,永远不会触发我的,因此绕过速率限制。 如何以优先

  • 根据请求主体中的session_type,我必须将请求映射到特定的POJO(JSON->JAVA POJO)。 例如,如果请求正文中的'session_type'是'typeX',那么请求应该映射到ClassX POJO。如果请求正文中的“session_type”是“type y”,那么请求应该映射到ClassY POJO。 如果有一种方法可以使用某种requestbody注释来完成它呢?

  • 我想扩展一个Spring应用程序的功能,包括一个HTTPendpoint,以接收贝宝即时支付通知。 Paypal在HTTP正文中发送这些内容,如下所示: MC_Gross=19.95&protection_eligibility=合格&address_status=确认状态s&txn_type=express_checkout&item_name=&mc_currency=usd&item_num