我正在尝试将url放入属性文件中的登录页面,并在xml-config中调用此属性。
<security:http auto-config="true" use-expressions="true">
<security:csrf disabled="true"/>
<security:form-login login-page="${login.url.login}" authentication-failure-url="${login.url.failure}" default-target-url="${login.url.succes}"
always-use-default-target="true"/>
<security:logout />
<security:intercept-url pattern="/favicon.ico" access="isAnonymous()" />
<security:intercept-url pattern="/login" access="isAnonymous()" />
<security:intercept-url pattern="/spring/**" access="isAnonymous()" />
<security:intercept-url pattern="/**" access="isAuthenticated()" />
</security:http>
<security:authentication-manager>
<security:authentication-provider user-service-ref="userAuthenticationProvider">
<security:password-encoder ref="passwordEncoder" />
</security:authentication-provider>
</security:authentication-manager>
<bean id="userAuthenticationProvider" class="com.security.services.implementations.CustomUserDetailsService"></bean>
<bean id="passwordEncoder" class="com.security.services.encoders.PasswordEncoder"></bean>
<beans profile="qa">
<context:property-placeholder location="classpath:properties/qa.properties" />
</beans>
<beans profile="dev">
<context:property-placeholder location="classpath:properties/dev.properties" />
</beans>
<beans profile="test">
<context:property-placeholder location="classpath:properties/test.properties" />
</beans>
在properties-file中包含以下内容:
login.url.login=https://www.......(url to login-page)
当我部署它时,它会给出以下错误消息:
引起:java.lang.IllegalArgumentException:无法在字符串值“$ {login.url.login}?logout”
中解析占位符'login.url.login'
找到属性文件,并且按原样读取此文件中定义的每个其他属性。读取的唯一属性是此属性。
另一方面,如果我把url硬编码在xml-config中,一切都很顺利。有没有办法用属性文件中的外部化URL来解决这个问题?