当我调用getThreadLocalRequest()
servlet 中的方法(扩展RemoteServiceServlet
)时,我总是得到 null。
public class UPS_LpnListRPCServiceImpl
extends RemoteServiceServlet
implements IUPS_LpnRPCService {
@Override
public String getUserInfoFromHeader() {
LOGGER.debug(" getUserInfoFromHeader: ");
HttpServletRequest req = this.getThreadLocalRequest();
if (req != null) {
//HttpSession session = req.getSession();
remote_user = req.getHeader("ct-remote-user");
LOGGER.debug("req != null");
} else {
remote_user = "";
LOGGER.debug("req == null");
}
LOGGER.debug(" getUserInfoFromHeader: remote_user = " + remote_user);
return remote_user;
}
}
在其他地方打电话:
IUPS_LpnRPCServiceAsync service = GWT.create(IUPS_LpnRPCService.class);
service.getUserInfoFromHeader(new AsyncCallbackSupport<String>(false) {
@Override
public void onSuccess(String remote_user) {
GWT.log("getting remote call");
defaultMainScreen.setUsername(remote_user);
GWT.log("remote_user = " + remote_user);
}
});