我有一个请求的url
http://192.168.99.128:8080/bill-yz-office-server/view/2020/01/03/MjAwMTAzNDk2MDkzMDE5.html
我想通过jfinal的contrller拦截上面的url并处理,于是我做了下面的配置
定义handler
public class StaticHandler extends Handler { public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) { if (target.indexOf('.') != -1) { return; } } }
添加handler
@Override public void configHandler(Handlers me) { me.add(new StaticHandler()); }
定义contrller拦截
public void configRoute(Routes me) { me.setMappingSuperClass(true); me.add("/view/**",ViewController.class);
访问测试,依然是返回404,没有进入我定义的controller
之后我在handler中将静态文件的后缀名去除,向后传递
public class StaticHandler extends Handler { public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) { int indexOf = target.indexOf('.'); if (indexOf != -1) { target = target.substring(0, indexOf); next.handle(target, request, response, isHandled); } } }
依然找不到我定义的Controller
isHandled[0] = true;