1。访问端口配置
编辑
%jboss-4.0.2%\server\default\deploy\jbossweb-tomcat55.sar\server.xml
将8080改为你希望访问的端口(8888)
<!--
A HTTP
/
1.1
Connector on port
8080
-->
<
Connector port
=
"
8888
"
address
=
"
${jboss.bind.address}
"
maxThreads
=
"
250
"
strategy
=
"
ms
"
maxHttpHeaderSize
=
"
8192
"
emptySessionPath
=
"
true
"
enableLookups
=
"
false
"
redirectPort
=
"
8443
"
acceptCount
=
"
100
"
connectionTimeout
=
"
20000
"
disableUploadTimeout
=
"
true
"
URIEncoding
=
"
UTF-8
"
/>
2。虚拟目录配置:
编辑
%jboss-4.0.2%\server\default\deploy\jbossweb-tomcat55.sar\server.xml
在 </Host>之前增加:
<
Context
path
="/test"
docBase
="F:\\test"
debug
="1"
reloadable
="true"
override
="true"
crossContext
="true"
/>
其中path 为虚拟目录名,docBase为硬盘路径(可为绝对路径)reloadable为类变更时是否重新加载
3。解决附件汉字问题:
a.编辑
%jboss-4.0.2%\server\default\deploy\jbossweb-tomcat55.sar\server.xml
在Connector 属性最后增加:URIEncoding="UTF-8"
<!--
A HTTP/1.1 Connector on port 8080
-->
<
Connector
port
="8888"
address
="$"
maxThreads
="250"
strategy
="ms"
maxHttpHeaderSize
="8192"
emptySessionPath
="true"
enableLookups
="false"
redirectPort
="8443"
acceptCount
="100"
connectionTimeout
="20000"
disableUploadTimeout
="true"
URIEncoding
="UTF-8"
/>
b.页面处理
将生成的附件名称进行编码转换:
<%
String
n2
=
"
Redhat9中文官方文档.rar
"
;
n2
=
java.net.URLEncoder.encode(n2,
"
UTF-8
"
);
%>
<
a
href
="Redhat9"
>
http://192.168.1.112:8080/zlsf/
<%
=
n2
%>
">Redhat9中文官方文档
</
a
>
4。解决汉字问题。
在:项目/WEB-INFweb.xml中增加:
<
filter
>
<
filter-name
>
Set Character Encoding
</
filter-name
>
<
filter-class
>
filters.SetCharacterEncodingFilter
</
filter-class
>
<
init-param
>
<
param-name
>
encoding
</
param-name
>
<
param-value
>
GBK
</
param-value
>
</
init-param
>
</
filter
>
<
filter-mapping
>
<
filter-name
>
Set Character Encoding
</
filter-name
>
<
url-pattern
>
/*
</
url-pattern
>
</
filter-mapping
>
其中
<param-value>GBK</param-value> 这里要设置GBK,而不是UTF8。为了解决标单提交后的中文问题。
filters.SetCharacterEncodingFilter 类文件在TOMCAT lib 目录下filters.jar文件中。
你只需要把filters.jar放入你应用目录下的LIB中即可。
5。虚拟主机配置
a.编辑
%jboss-4.0.2%\server\default\deploy\jbossweb-tomcat55.sar\server.xml
在 </Engine>之前添加:
<
Host
name
="www.ytiic.com"
>
<
Alias
>
www2.ytiic.com
</
Alias
>
--〉别名,通过这个名字可以访问www.ytiic.com下的应用。
<
Alias
>
ytiic.com
</
Alias
>
--〉同上
<!--
Default context parameters
-->
<
DefaultContext
cookies
="true"
crossContext
="true"
override
="true"
/>
</
Host
>
b.在这个目录下:%jboss-4.0.2%\server\default\deploy
创建一个目录:test.war(你的虚拟目录加.war)之后在其下创建WEB-INF目录
在WEB-INF下创建:jboss-web.xml 文件,内容如下:
<
jboss-web
>
<
context-root
>
/
</
context-root
>
<
virtual-host
>
www.ytiic.com
</
virtual-host
>
</
jboss-web
>
虚拟主机配置完成!
当jboss启动后,会自动对应2个配置文件中的虚拟主机名。
7.禁止文件目录列表
编辑
%jboss-4.0.2%\server\default\deploy\jbossweb-tomcat55.sar\conf\web.xml
把listing设置为false
<
servlet
>
<
servlet-name
>
default
</
servlet-name
>
<
servlet-class
>
org.apache.catalina.servlets.DefaultServlet
</
servlet-class
>
<
init-param
>
<
param-name
>
debug
</
param-name
>
<
param-value
>
0
</
param-value
>
</
init-param
>
<
init-param
>
<
param-name
>
listings
</
param-name
>
<
param-value
>
true
</
param-value
>
</
init-param
>
<
load-on-startup
>
1
</
load-on-startup
>
</
servlet
>
转自:
http://liuq.spaces.live.com/default.aspx?_c01_blogpart=blogmgmt&_c=blogpart&nextPost=true&postPH=cns!5E9E09C446E9CD3F!271