DefaultRedirectStrategy
client.setRedirectHandler(new DefaultRedirectHandler() {
@Override
public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
boolean isRedirect = super.isRedirectRequested(response, context);
if (!isRedirect) {
int responseCode = response.getStatusLine().getStatusCode();
if (responseCode == 301 || responseCode == 302) {
return true;
}
}
return isRedirect;
}
});
/**
* @since 4.2
*/
protected boolean isRedirectable(final String method) {
for (final String m: REDIRECT_METHODS) {
if (m.equalsIgnoreCase(method)) {
return true;
}
}
return false;
}
/**
* Redirectable methods.
*/
private static final String[] REDIRECT_METHODS = new String[] {
HttpGet.METHOD_NAME,
HttpHead.METHOD_NAME
};
http://blog.csdn.net/chszs/article/details/16996489
/**
* spring中Around通知
* @param joinPoint
* @return
* @throws Throwable
*/
@Around("com.leanyu.lcsystem.pointcut.PointcutsDefinition.inServiceLayer()")
public Object checkPermissionAround( ProceedingJoinPoint joinPoint )
{
try
{
Object[] args = joinPoint.getArgs();
AbstractRequest request = (AbstractRequest)args[0];
int userId = request.getUserId();
String password = request.getPassword();
Signature signature = joinPoint.getSignature();
String service = signature.getDeclaringTypeName();
String method = signature.getName();
if ( checkPermission.hasServicePermission(userId, service , method , password) )
{
Object result = joinPoint.proceed( args );
return result;
}
}catch(Throwable e)
{
logger.error(e.toString(), e);
}
return null;
}