를 반환, 나는 어떤 클라이언트를 통해 현재 로그인 한 사용자의 사용자 이름을 얻기 위해 목표로 다음과 같은 편안한 클래스SessionContext.getCallerPrincipal.getName은() 내 자바 EE 응용 프로그램에서 "익명"
@Path("userProfile")
@Stateless
public class UserProfileRestful {
@Resource
private SessionContext sessionContext;
@Path("userName")
@GET
@Produces(MediaType.Text_Palin)
public String findCurrentUserName(){
return sessionContext.getCallerPrincipal.getName();
}
}
을 선언합니다. 내가 이름 "참고 MyUser"으로 로그인 한 후
, 방금 새 탭
http://localhost:8080/MyApp/rest/userProfile/userName
에서 웹 브라우저에 다음 URL을 붙여 넣기하고 표시된 반응은 예상대로였다 "참고 MyUser를".
Ext.Ajax.Request({
url : "http://localhost:8080/MyApp/rest/userProfile/userName",
success : function(response,options){
alert('username : ' + response.responseText);
},
failure : function(){
alert('request failed');
}
});
경고 결과가 "익명"이었다, 나는 아직도 해요 비록 다음과 같이
는 지금은 Ajax 요청을 수행하는 다른 ExtJS로 응용 프로그램 (즉, 어떤 인증이 필요하지 않습니다) 내에서 해당 사용자 이름을 얻기 위해 시도 같은 세션에서 "myuser"로 로그인했습니다.그래서 두 번째 경우에 호출자 주체가 변경되는 이유는 무엇입니까?
글쎄, 그것의 수행