Home > OS >  Spring: How to add static final object to bean constructor as argument in XML config
Spring: How to add static final object to bean constructor as argument in XML config

Time:09-13

I'm adding csrf security to a Spring-MVC project I'm working on. I'm using Spring security 5.2.15 and am following this answer here to disable csrf for a particular URL. csrf Filter request Matcher class

how do I Add this to as an argument into my csrfMatcher bean in my XML config file?

CodePudding user response:

I solved this by applying the bean tag and utilizing the class the static object uses with $ to reference it.

<b:bean id="csrfMatcher" >
    <b:constructor-arg name="requestMatchers">
    <b:list>
      <b:bean  />
      <b:bean >
        <b:constructor-arg>
          <b:bean 
            c:pattern="login.html"/>
        </b:constructor-arg>
      </b:bean>
    </b:list>
    </b:constructor-arg>
  </b:bean>
  • Related