基于自主学习的目的,搭建了一个jfinal的maven项目,如下图:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="Monitor" version="3.0"> <display-name>myJfinal</display-name> <filter> <filter-name>JFinal</filter-name> <filter-class>com.jfinal.core.JFinalFilter</filter-class> <init-param> <param-name>configClass</param-name> <param-value>com.jfinal.study.config.MyJfinalConfig</param-value> </init-param> </filter> <filter-mapping> <filter-name>JFinal</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
基本配置:
/** * */ package com.jfinal.study.config; 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.render.ViewType; import com.jfinal.study.controller.MyController; import com.jfinal.template.Engine; /** * @author lucio * */ public class MyJfinalConfig extends JFinalConfig { @Override public void configConstant(Constants me) { me.setDevMode(true); me.setViewType(ViewType.VELOCITY); } @Override public void configRoute(Routes me) { me.setBaseViewPath("/WEB-INF/tmpl/"); me.add("/", MyController.class); } @Override public void configEngine(Engine me) { } @Override public void configPlugin(Plugins me) { } @Override public void configInterceptor(Interceptors me) { } @Override public void configHandler(Handlers me) { } }
控制层:
/** * */ package com.jfinal.study.controller; import com.jfinal.core.Controller; /** * @author lucio * */ public class MyController extends Controller { public void index() { render("index.html"); } }
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.study.jfinal</groupId> <artifactId>myJfinal</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>myJfinal Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal</artifactId> <version>3.0</version> </dependency> </dependencies> <build> <finalName>myJfinal</finalName> </build> </project>
启动tomcat界面:
四月 05, 2017 2:22:43 下午 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;E:\Program Files\Java\jdk1.7.0_45\bin;E:\Program Files\Java\jdk1.7.0_45\jre\bin;C:\Program Files\VanDyke Software\Clients\;E:\Program Files\Git\cmd;E:\Program Files\TortoiseGit\bin;C:\Users\lucio\AppData\Local\Microsoft\WindowsApps;;. 四月 05, 2017 2:22:43 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:myJfinal' did not find a matching property. 四月 05, 2017 2:22:43 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-bio-8080"] 四月 05, 2017 2:22:43 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["ajp-bio-8009"] 四月 05, 2017 2:22:43 下午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 493 ms 四月 05, 2017 2:22:43 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 四月 05, 2017 2:22:43 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.54 四月 05, 2017 2:22:43 下午 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter JFinal java.lang.ClassNotFoundException: com.jfinal.core.JFinalFilter at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 四月 05, 2017 2:22:43 下午 org.apache.catalina.core.StandardContext startInternal 严重: Error filterStart 四月 05, 2017 2:22:43 下午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/myJfinal] startup failed due to previous errors 四月 05, 2017 2:22:43 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-bio-8080"] 四月 05, 2017 2:22:43 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-bio-8009"] 四月 05, 2017 2:22:43 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 458 ms
在网上找了很久的解决方案,没有成效,求大牛解惑。
项目:JFinal