jfinal访问jsp报错

暴走的喵咪 发布于 2015/04/11 18:21
阅读 1K+
收藏 0

@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)

 

加载中
0
红星xx
红星xx
估计要 添加 jsp 包
0
暴走的喵咪

package com.demo.common;

import com.demo.common.controller.BlogController;
import com.demo.common.model.Blog;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;

public class CommonConfig extends JFinalConfig {

 @Override
 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");
 }

 @Override
 public void configHandler(Handlers me) {
  // TODO Auto-generated method stub

 }

 @Override
 public void configInterceptor(Interceptors me) {
  // TODO Auto-generated method stub

 }

 @Override
 public void configPlugin(Plugins me) {
  // TODO Auto-generated method stub
  // 配置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("blog", Blog.class); // 映射blog 表到 Blog模型
 }

 @Override
 public void configRoute(Routes me) {
  // TODO Auto-generated method stub
  me.add("/blog", BlogController.class);
 }
 public static void main(String[] args) {
  JFinal.start("WebRoot", 80, "/", 5);
 }

路由添加了

0
JFinal
JFinal
      错误提示 java.lang.NoSuchMethodError ,可能是 jsp 相关 jar 包的版本不对,去 jfinal 官网下载 jfinal-demo-for-jsp.zip 这个项目,在这上面直接开发:http://jfinal.com
JFinal
JFinal
回复 @暴走的喵咪 : 已经解释了,正是 jar 包不对,添加了 Java EE 5 Library 后里面的 jsp 相关 jar 包不对
暴走的喵咪
解决了,我把 Java EE 5 Library移除就好了,不过不明白原因,能请解释下吗
0
SkipperD
SkipperD
应该是缺包了
返回顶部
顶部