@JFinal 你好,想跟你请教个问题:我是新手,刚接触jfinal,但遇到个错误,希望能教我怎么解决。我是按教程做的,然后测试网页访问index.jsp就报错500
public void configConstant(Constants me) {
// TODO Auto-generated method stub
loadPropertyFile("config.properties");
me.setDevMode(getPropertyToBoolean("devMode", false));
me.setViewType(ViewType.JSP);
me.setBaseViewPath("/WEB-INF/view");
}
public class BlogController extends Controller {
public void index(){
render("index.jsp");
}
}
控制台错误如下
JFinal action report -------- 2015-04-11 15:33:03 ------------------------------
估计要添加jsp包
packagecom.demo.common;
importcom.demo.common.controller.BlogController;
importcom.demo.common.model.Blog;
importcom.jfinal.config.Constants;
importcom.jfinal.config.Handlers;
importcom.jfinal.config.Interceptors;
importcom.jfinal.config.JFinalConfig;
importcom.jfinal.config.Plugins;
importcom.jfinal.config.Routes;
importcom.jfinal.core.JFinal;
importcom.jfinal.plugin.activerecord.ActiveRecordPlugin;
importcom.jfinal.plugin.c3p0.C3p0Plugin;
importcom.jfinal.render.ViewType;
publicclassCommonConfigextendsJFinalConfig{
@Override
publicvoidconfigConstant(Constantsme){
//TODOAuto-generatedmethodstub
loadPropertyFile("config.properties");
me.setDevMode(getPropertyToBoolean("devMode",false));
me.setViewType(ViewType.JSP);
me.setBaseViewPath("/WEB-INF/view");
}
@Override
publicvoidconfigHandler(Handlersme){
//TODOAuto-generatedmethodstub
}
@Override
publicvoidconfigInterceptor(Interceptorsme){
//TODOAuto-generatedmethodstub
}
@Override
publicvoidconfigPlugin(Pluginsme){
//TODOAuto-generatedmethodstub
//配置C3p0数据库连接池插件
C3p0Pluginc3p0Plugin=newC3p0Plugin(getProperty("jdbcUrl"),getProperty("user"),getProperty("password").trim());
me.add(c3p0Plugin);
//配置ActiveRecord插件
ActiveRecordPluginarp=newActiveRecordPlugin(c3p0Plugin);
me.add(arp);
arp.addMapping("blog",Blog.class); //映射blog表到Blog模型
}
@Override
publicvoidconfigRoute(Routesme){
//TODOAuto-generatedmethodstub
me.add("/blog",BlogController.class);
}
publicstaticvoidmain(String[]args){
JFinal.start("WebRoot",80,"/",5);
}
路由添加了
错误提示<spanstyle="font-family:微软雅黑,Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">java.lang.NoSuchMethodError ,可能是jsp相关jar包的版本不对,去jfinal官网下载jfinal-demo-for-jsp.zip这个项目,在这上面直接开发:http://jfinal.com回复<aclass='referer'target='_blank'>@暴走的喵咪:已经解释了,正是jar包不对,添加了JavaEE5Library后里面的jsp相关jar包不对解决了,我把JavaEE5Library移除就好了,不过不明白原因,能请解释下吗应该是缺包了版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。