tomcat5在win2k下配置的两点预备工作

来源:互联网 发布:oracle数据库视频教程 编辑:程序博客网 时间:2024/04/29 00:31

chinese code question

1 在web.xml中添加过滤器SetCharacterEncodingFilter,解决Post

2 在server.xml中的节<connection ....最后添加 uriEncoding="GBK",用来解决Get,如下:

    <Connector   port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000"
               disableUploadTimeout="true" URIEncoding="GBK" />

3 在jsp页首都加上<%@ page contentType="text/html; charset=GBK" %><%@ page contentType="text/html; charset=GBK" %><%@ page contentType="text/html; charset=GBK" %><%@ page contentType="text/html; charset=GBK" %>

4 如果数据库使用mysql,连接的url写成这样就可以了: jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=UTF-8,当然,如果是在xml文件中写的话要使用屏蔽符的。如:

<![CDATA[jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=UTF-8]]>

work with apache(2.0.49)

jdk1.4环境、apache和tomcat的安装过程省略。
下文中假定apache2的安装路径为Apache_Home,tomcat5的为Tomcat_Home

1.关闭两个服务,将mod_jk2.so拷贝到Apache_Home/modules/
2.修改配置文件Apache_Home/conf/httpd.conf,加上以下一行
  LoadModule jk2_module modules/mod_jk2.so
3.在Apache_Home/conf/下,建立属性文件workers2.properties 内容为
  
   [shm]
   file=${serverRoot}/logs/shm.file
   size=1048576
   #The socket channel
   [channel.socket:localhost:8009]
   port=8009
   host=127.0.0.1
   #define the worker
   [ajp13:localhost:8009]
   channel=channel.socket:localhost:8009
   #uri mapping
   [uri:/*.jsp]
   [uri:/*.do]
   worker=ajp13:localhost:8009
  
4.修改Tomcat_Home/conf/jk2.properties,增加以下内容

  handler.list=apr,request,channelJni
  channelSocket.port=8009
  apr.jniModeSo=Apache_Home/modules/mod_jk2.so
 
5.此时,最好重启一下机器,有两点要注意,首先,如果首页为jsp文件,需要特别配置,在httpd.conf中这一行 DirectoryIndex index.html index.html.var 后加上index.jsp就可以了。
 第二,根路径最好统一起来,要么修改tomcat的server.xml,要么修改httpd.conf
 否则,jsp相关的图片、js等文件会由于相对路径的关系而找不到。例如,如下给server.xml增加一个虚拟目录:<Context path="/newWeb" docBase="Apache_Home/htdocs/jzadmin" debug="0" reloadable="true" > </Context>

原创粉丝点击