나는 spring-mvc 및 spring 보안을 사용하여 응용 프로그램을 개발 중입니다.ajax 호출에서 인증 예외 감지
내 컨트롤러에서 반환 된 HTML 데이터 내 페이지 내부 div
채울하기 위해 뷰 레이어에서이 작은 스크립트를 사용하고 있습니다 :
$.ajax({
type : 'GET',
url : $("#"+ event.args.element.id+ "Url").val(),
dataType : 'html',
success : function(data){
$("#ContentPanel").html(data);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert("Error!!!");
}
});
을하지만 경우 때문에 (예를 들어, 인증되지에서 사용자 세션 만료), div는 로그인 페이지에서 html로 채워집니다. 어떻게 그것을 피할 수 있으며, 봄은보기에 스크립트에 이러한 오류 정보를 제공할까요? 어떤 힌트
<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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<http auto-config="true" use-expressions="true">
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
<form-login
login-page="/login"
login-processing-url="/resources/j_spring_security_check"
authentication-failure-url="/login?login_error=t"/>
<logout logout-url="/resources/j_spring_security_logout"/>
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/url1**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/url2/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
<beans:bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="userDetailsService" />
</beans:bean>
<beans:bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="userDetailsService" />
</beans:bean>
<beans:bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
<beans:constructor-arg>
<beans:ref bean="authenticationProvider"/>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="userDetailsService" class="it.cpmapave.fgas.aziende.service.jpa.UserDetailsServiceImpl" />
<authentication-manager>
<authentication-provider user-service-ref="userDetailsService">
<password-encoder hash="sha-256"/>
</authentication-provider>
</authentication-manager>
<global-method-security pre-post-annotations="enabled" />
이
감사 :
여기 내 봄 보안 구성입니다!
리디렉션 상태 코드 303을 보내려면 스프링 보안을 구성하고 아약스 호출의 상태 코드를 확인하고 적절한 조치를 취하십시오. – apurvc