在jfinal的handle中加入java
HandlerKit.redirect301("http://10.10.3.144:8080/bbb.rar", request, response, arg3);ruby
有一些本身的業務邏輯,能夠忽略ide
package com.dsideal.CommonIntercptor; import java.util.concurrent.TimeoutException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.rubyeye.xmemcached.exception.MemcachedException; import com.dsideal.Util.SigarTest; import com.jfinal.handler.Handler; import com.jfinal.kit.HandlerKit; import com.jfinal.plugin.memcached.MemcachedKit; import com.jfinal.plugin.memcached.MemcachedPlugin; import com.jfinal.render.RenderFactory; public class ResourceHandler extends Handler{ /** * 攔截器,放開報表 */ @Override public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] arg3) { // MemcachedPlugin memcachedPlugin = new MemcachedPlugin("10.10.3.151:11211"); // memcachedPlugin.start(); int index = target.indexOf("ReportServer"); if (index == -1){ // if (request.getRequestURI().indexOf(".") != -1) { // if (request.getRequestURI().substring(request.getRequestURI().lastIndexOf('.')).toLowerCase().equals(".zip")) { try { if(new Long((Long)MemcachedKit.get("dfTxBytesMb")).intValue() > 2) { System.out.println("TxBytes(每秒發送的總字節數) = " + MemcachedKit.get("dfTxBytesMb") + "MB"); SigarTest.printA(); HandlerKit.redirect301("http://10.10.3.36:8817/aaa.rar", request, response, arg3); } else { System.out.println("TxBytes(每秒發送的總字節數) = " + MemcachedKit.get("dfTxBytesMb") + "MB"); SigarTest.printB(); HandlerKit.redirect301("http://10.10.3.144:8080/bbb.rar", request, response, arg3); } } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MemcachedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // } // } nextHandler.handle(target, request, response, arg3); } } }