开发者社区> 问答> 正文

jfinal访问jsp报错?报错

@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 ------------------------------
Controller  : com.demo.common.controller.BlogController.(BlogController.java:1)
Method      : index
--------------------------------------------------------------------------------
index
2015-4-11 15:33:03 com.jfinal.core.ActionHandler error
严重: /blog
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getJspConfigDescriptor()Ljavax/servlet/descriptor/JspConfigDescriptor;
 at org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:106)
 at org.apache.jasper.compiler.JspConfig.init(JspConfig.java:196)
 at org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:259)
 at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
 at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
 at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
 at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:276)
 at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
 at com.jfinal.render.JspRender.render(JspRender.java:67)
 at com.jfinal.core.ActionHandler.handle(ActionHandler.java:92)
 at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
 at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
 at org.eclipse.jetty.server.Server.handle(Server.java:365)
 at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
 at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
 at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
 at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
 at java.lang.Thread.run(Thread.java:619)

 

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

    估计要添加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移除就好了,不过不明白原因,能请解释下吗应该是缺包了

    2020-06-14 16:49:47
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载