论坛首页 Java版 Tomcat

tomcat小技巧

浏览 1568 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2007-12-04 关键字: tomcat
1.apr
许多朋友可能在启动tomcat的时候都会看到类似这样的信息:
org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Java\jre\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS

出现这种情况是这表示没有找到APR
简要解决办法:去 http://tomcat.heanet.ie/native/ 下载编译好的 tcnative-1.dll 文件因此可以到下面网站下载新版:http://tomcat.heanet.ie/native/,目前最新为1.1.10,拷贝至jdk\bin下,再启动就可以成功加载APR了。
org.apache.catalina.core.AprLifecycleListener init
信息: Loaded Apache Tomcat Native library 1.1.10.
org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], random [true].

2.URIEncoding
有时候在做开发的时候经常发现文本框输入的中文到了程序中成了乱码,其实是因为在端口监听部分缺少编码。
 URIEncoding="UTF-8" 

解决方法如下:
原始部分
8080端口上
<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

修改后
<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8" />

8009端口 ajp跳转服务上,关于这个端口在apache http 做跳转时,要相当注意
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

修改后
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />

这样,服务器得到的中文字符就不会再有乱码了。
   
论坛首页 Java版 Tomcat

跳转论坛:
JavaEye推荐