开发者社区> 问答> 正文

jfinal 拦截器报错?报错

@JFinal

请帮我看一下

我项目中,使用了拦截器之后会报错,将拦截器闭屏掉就可以运行,但是用debug看,没有进拦截器,也没有进我的index()方法。

拦截器中的代码已经被我闭屏掉了

附上代码与错误信息,服务器用的是tomcat

/**
	 * 配置常量
	 */
	@Override
	public void configConstant(Constants me) {
		// 加载少量必要配置,随后可用getProperty(...)获取值
		loadPropertyFile("DBConfig.txt");
		me.setDevMode(getPropertyToBoolean("devMode", true));
	}
	
	/**
	 * 配置路由
	 */
	@Override
	public void configRoute(Routes me) {
		me.add("/", LoginController.class);
		me.add("/login", LoginController.class);
	}
	
	/**
	 * 配置插件
	 */
	@Override
	public void configPlugin(Plugins me) {
		// 配置C3p0数据库连接池插件
		C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password").trim());
		me.add(c3p0Plugin);
		
		// 配置ActiveRecord插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		
		arp.addMapping("account", Account.class);
	}
	
	/**
	 * 配置全局拦截器
	 */
	@Override
	public void configInterceptor(Interceptors me) {
		me.add(new MyIntercepter());
	}
	
	/**
	 * 配置处理器
	 */
	@Override
	public void configHandler(Handlers me) {
		me.add(new ContextPathHandler());
	}
	
	@Override
	public void afterJFinalStart(){
	    try {
			FreeMarkerRender.getConfiguration()
			.setSharedVariable("thispath", Constant.PATH);
		} catch (TemplateModelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
public class MyIntercepter implements Interceptor{
	public void intercept(ActionInvocation ai) {
	}

}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>xx</title>
<base />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet">
<link rel="stylesheet">
<style type="text/css">
body {
 padding-top: 40px;
 padding-bottom: 40px;
 background-color: #f5f5f5;
}


.div-signin {
 height: 100px;
}


.form-signin {
 max-width: 300px;
 padding: 19px 29px 29px;
 margin: 0 auto 20px;
 background-color: #fff;
 border: 1px solid #e5e5e5;
 -webkit-border-radius: 5px;
 -moz-border-radius: 5px;
 border-radius: 5px;
 -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
 -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
 box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}


.form-signin .form-signin-heading,.form-signin .checkbox {
 margin-bottom: 10px;
}


.form-signin input[type="text"],.form-signin input[type="password"] {
 font-size: 16px;
 height: auto;
 margin-bottom: 15px;
 padding: 7px 9px;
}
</style>


 <script src="js/jquery.js"></script>
 <script src="js/bootstrap-transition.js"></script>
 <script src="js/bootstrap-alert.js"></script>
 <script src="js/bootstrap-modal.js"></script>
 <script src="js/bootstrap-dropdown.js"></script>
 <script src="js/bootstrap-scrollspy.js"></script>
 <script src="js/bootstrap-tab.js"></script>
 <script src="js/bootstrap-tooltip.js"></script>
 <script src="js/bootstrap-popover.js"></script>
 <script src="js/bootstrap-button.js"></script>
 <script src="js/bootstrap-collapse.js"></script>
 <script src="js/bootstrap-carousel.js"></script>
 <script src="js/bootstrap-typeahead.js"></script>
 
</head>


<body>
 <div class="container">
 <div class="div-signin"></div>
 <form class="form-signin" id="myForm" action="login/loginto" method="post">
 <h2 class="form-signin-heading">登录</h2>
 <input name="username" type="text" class="input-block-level" placeholder="输入账户名">
 <input name="pwd" type="password" class="input-block-level" placeholder="密码">
 <button id="loginBtn" class="btn  btn-primary" type="submit">登录</button>
 <span style="color: red;">${msg!}</span>
 </form>
 </div>
</body>
</html>

 
 
 
 
 
public class LoginController extends Controller {
	
	public void index(){
		getSession().removeAttribute("username");
		render("/login/login.html");
	}
}
JFinal action report -------- 2013-08-31 16:45:50 ------------------------------
Controller  : industry.controller.finance.LoginController.(LoginController.java:1)
Method      : index
Interceptor : industry.intercepter.MyIntercepter.(MyIntercepter.java:1)
--------------------------------------------------------------------------------

2013-08-31 16:45:50
[ERROR]-[Thread: http-8080-1]-[com.jfinal.core.ActionHandler.handle()]: /login/
com.jfinal.render.RenderException: java.io.FileNotFoundException: Template /login/index.html not found.
	at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:128)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:92)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:47)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.FileNotFoundException: Template /login/index.html not found.
	at freemarker.template.Configuration.getTemplate(Configuration.java:495)
	at freemarker.template.Configuration.getTemplate(Configuration.java:458)
	at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:124)
	... 15 more

展开
收起
爱吃鱼的程序员 2020-06-22 17:07:25 676 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    拦截器方法中,必须调用ai.invoke()才能进controller是你的模板文件路径有问题,检查一下吧回复<aclass='referer'target='_blank'>@刘于毅:建议你仔细读一下jfinal手册回复<aclass='referer'target='_blank'>@刘于毅:你自己配置的怎么说没有,你看看你的LoginController里的index:publicclassLoginControllerextendsController{publicvoidindex(){getSession().removeAttribute("username");render("/login/login.html");}}回复<aclass='referer'target='_blank'>@iSea:这样写就太死了,而且我项目里面就没有render("/login/index.html");这种跳转,不知道为什么他会直接跳到那边去?回复<aclass='referer'target='_blank'>@刘于毅:然后访问http://domain/或者http://domain/login回复<aclass='referer'target='_blank'>@刘于毅:就你目前的配置,请在根目录下创建login文件夹,并把你的页面文件以index.html命名,放到其中

    2020-06-22 17:07:43
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第7讲】:Spring Boot 2.0安全机制与MVC身份验证实战(Java面试题) 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载