使用JFinal.start()方法启动项目,主页jsp加载失败500错误

Demon_N 发布于 2017/06/04 08:51
阅读 224
收藏 0

@JFinal 你好,想跟你请教个问题:

  我在学习JFinal,创建网站首页时使用JFinal.start()方法启动项目,主页jsp加载失败500错误.

开发环境IDEA,使用Gradle构建的项目.

工程目录如下:

gradle dependencies如下:

dependencies {

    testCompile group: 'junit', name: 'junit', version: '4.12'

    compile group: 'com.jfinal', name: 'jfinal', version: '3.1'

    compile group: 'com.jfinal', name: 'jetty-server', version: '8.1.8'

    // https://mvnrepository.com/artifact/com.alibaba.druid/druid-wrapper
    compile group: 'com.alibaba.druid', name: 'druid-wrapper', version: '0.2.9'

    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.42'

}

main方法如下:

public class MainApplication {
	public static void main(String[] args) {
		JFinal.start("src/main/webapp", 80, "/");
	}
}

MyJFinalConfig如下:

package demo;

import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.render.ViewType;
import com.jfinal.template.Engine;

public class DemoConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		me.setEncoding("UTF-8");
		me.setDevMode(true);
//		me.setViewType(ViewType.JSP);
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/hello", HelloController.class);
		me.add("/", IndexController.class);
	}

	@Override
	public void configEngine(Engine me) {
		
	}

	@Override
	public void configPlugin(Plugins me) {

		DruidPlugin dp = new DruidPlugin("jdbc:mysql://localhost:3306/db_final_demo?useSSL=false&Unicode=true&characterEncoding=UTF-8",
				"root", "123456");
		me.add(dp);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
		me.add(arp);
		arp.addMapping("user", User.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		
	}

	@Override
	public void configHandler(Handlers me) {
		
	}

}

IndexController如下:

package demo;

import com.jfinal.core.Controller;

public class IndexController extends Controller {
	public void index(){
		renderJsp("/main.jsp");
//		render("main.html");
	}
}

main.jsp如下:

<%--
  Created by IntelliJ IDEA.
  User: N_Ice
  Date: 2017/6/3
  Time: 11:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>jfinal_demo</title>
  </head>
  <body>
  Hello JFinal
  </body>
</html>

错误信息:

期待您的回复,谢谢!!!

加载中
0
JFinal
JFinal

jetty 是模块化的,要使用 jsp 功能,需要引入相关 jar 包:

<dependency>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-jsp</artifactId>
  <version>8.1.8.v20121106</version>
  <scope>provided</scope>
</dependency>

 

Demon_N
Demon_N
回复@JFinal : 解决了,谢谢!!!
返回顶部
顶部