第一范文网 - 专业文章范例文档资料分享平台

常见问题

来源:用户分享 时间:2025/7/21 4:20:47 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

作为中国优秀的开源项目之一JFinal有着极速开发的好处,是中小型应用开发的首选。在导师的建议下,我使用了JFinal来开发一个Java服务端应用,官方教程非常简单,就几十页(当然是中文的),学起来很快。然而在开发过程中肯定会遇到这样那样“无厘头”的问题,如何使用JFinal开发参考官方文档或网上某些人的教程即可,我再重写一遍也无多大意义,我这篇文章仅记录自己在使用JFinal开发过程中遇到的问题及注意事项,这样更有参考价值,也希望大家在遇到类似的问题后能及时找到解决方案,提高开发效率。

JFinal开发问题集锦

1. 中文乱码问题

这是几乎每个进行Java web开发的程序员都遇到过的问题,不同技术或框架处理的方式可能不太一样,对JFinal来说,有以下几个配置字符集的地方:

(1)Config配置:

YourJFinalConfig.configConstant(Constants me) {me.setEncoding(\

(2)数据库连接配置:

jdbcUrl = jdbc:mysql://127.0.0.1/jfinal?characterEncoding=utf8

(3)如果是页面发送 GET 请求,中文字符需要 encoding,除非在 tomcat 的 server.xml 中的 Connector 标记中添加了 URIEncoding=\属性

(4)如果是 jsp 页面:

<%@ page language=\pageEncoding=\

(5)如果是其它 html 页面:

(6)另外 eclipse workspace 的字符编码最好也配置成 utf-8

2. “Illegal access”问题

出现这种问题的原因很多,比如我遇到的有以下3种:

情况1:INFO: Illegal access: this web application instance has been stopped already. Could not load com.mysql.jdbc.authentication.MysqlOldPasswordPlugin. The eventualfollowing stack trace is caused by an error thrown for debugging purposes as wellas to attempt to terminate the thread which caused the illegal access, and has no functional impact.情况2:INFO: Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.c3p0.ConnectionCustomizer. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.情况3:INFO: Illegal access: this web application instance has been stopped already. Could not load

com.mchange.v2.resourcepool.BasicResourcePool$1. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.

解决方法:查看上述日志,可能会很明显的看到下面很多的exception。都是this web application instance has been stopped already以及Could not load XX Class。但是不要被这些异常迷惑,他们只是结果而不是原因。那么如果查找原因,可以通过查找error-debug日志文件来解决。

error-debug日志文件日志文件默认是不生成的,我们需要通过log配置文件来设置让其生成,具体方法如下:

(1)在WEB-INF/classes目录下新建logging.properties,内容如下: handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################

org.apache.juli.FileHandler.level = FINE org.apache.juli.FileHandler.directory = ${应用目录}/logs org.apache.juli.FileHandler.prefix = error-debug.

java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

(2)重新启动应用,指定目录下会有一个error-debug.yyyy-mm-ss.log的错误日志,通过分析上述日志可以找到问题发生的真正原因,然后进行解决。

3. “Plugin start error”问题

java.lang.RuntimeException: Plugin start error:

com.jfinal.plugin.activerecord.ActiveRecordPlugin.java.sql.SQLException: Connections could not be acquired from the underlying database!

at com.jfinal.core.Config.startPlugins(Config.java:95) at com.jfinal.core.Config.configJFinal(Config.java:48) at com.jfinal.core.JFinal.init(JFinal.java:67)

at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49) at

org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277) at

org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258) at

org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382) at

org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:103) at

org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4649) at

org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5305)

解决方法:删除跟jetty相关的jar包,因为我是在Tomcat下部署的,而JFinal自带的是jetty服务器。

4. 启动时老是出现“jfinal config it in web.xml”错误

解决方法:删除web.xml中默认生成的下面这段:

index.html index.htm index.jsp default.html

搜索更多关于: 常见问题 的文档
常见问题.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c8nv7n93apu0a6rj16zo5_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top