1.环境变量设置问题
1.1 java环境变量
JAVA_HOMe=c:\j2sdk1.6
1.2 Tomcat环境变量
TOMCAT_HOME=c:\tomcat6
2.端口冲突
HTTP的8080端口冲突:
tomcat的HTTP服务的端口默认为8080.
如果启动报以下错误:
java.net.BindException:cannot assign requested address:JVM_Bind:8080
......
则需要修改$CATALINA_HOME/conf/server.xml中端口的值,重启tomcat。
可以用netstat -p tcp 命令查看TCP监听的端口.
3. 中文字符解决方案
3.1 HTML中文编码转换
head之间加入 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
或者修改MIME编码:
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html; charset=utf-8</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html; charset=utf-8</mime-type>
</mime-mapping>
3.2 JSP中文编码
(1) <%@page language="java" contentType="text/html; charset=utf-8"%>
(2) request.setCharacterEncoding("utf-8");
(3) 使用编码过滤器:
public class CharacterEncodingFilter implements Filter{
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException,
ServletException{
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
chain.doFilter(request, response);
}
}
web.xml:配置过滤器。
(4) web.xml添加如下配置:
<jsp-config>
<jsp-property-group>
<page-encoding>utf-8</page-encoding>
<jsp-property-group>
</jsp-config>
(5) 配置编码过滤参数。
server.xml中的JspServlet设置中文编码:
<init-param>
<param-name>javaEncoding</param-name>
<param-value>utf-8</param-value>
</init-param>
也可以设置SSI、CGI文件的编码参数。
(6) 修改server.xml.
在Connector中加入URIEncoding="utf-8".
<Connector port="80" maxThreads="150" .... URIEncoding="utf-8"/>
4. 调试方法:
4.1 解读日志文件:
Tomcat的logs目录下基本的日志文件。
4.2 URL和Http会话:
$telnet localhost 80
分享到:
相关推荐
apache-tomcat-9.0.45-windows-x64apache-tomcat-9.0.45-windows-x64apache-tomcat-9.0.45-windows-x64apache-tomcat-9.0.45-windows-x64apache-tomcat-9.0.45-windows-x64apache-tomcat-9.0.45-windows-x64apache-...
apache-tomcat-8.5.78-windows-x64安装包 apache-tomcat-8.5.78-windows-x64安装包 apache-tomcat-8.5.78-windows-x64安装包 apache-tomcat-8.5.78-windows-x64安装包 apache-tomcat-8.5.78-windows-x64安装包 ...
最新版windows apache-tomcat-8.5.70-windows-x64.zip最新版windows apache-tomcat-8.5.70-windows-x64.zip
apache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-tomcat-9.0.45-srcapache-...
最新版windows apache-tomcat-8.5.66-windows-x64.zip最新版windows apache-tomcat-8.5.66-windows-x64.zip
最新版windows apache-tomcat-9.0.46-windows-x64.zip最新版windows apache-tomcat-9.0.46-windows-x64.zip
最新版 apache-tomcat-8.5.59--x64.zip
最新版windows apache-tomcat-9.0.54-windows-x64.zip最新版windows apache-tomcat-9.0.54-windows-x64.zip
最新版windows apache-tomcat-9.0.68-windows-x64.zip最新版windows apache-tomcat-9.0.68-windows-x64.zip
最新版windows apache-tomcat-10.0.27-windows-x64.zip最新版windows apache-tomcat-10.0.27-windows-x64.zip
apache-tomcat-10.0.8-windows-x64.zip、 apache-tomcat-10.0.8-windows-x86.zip、 apache-tomcat-10.0.8-deployer.tar.gz、 apache-tomcat-10.0.8-deployer.zip、 apache-tomcat-10.0.8-embed.tar.gz、 apache-...
apache-tomcat-7.0.100-windows-x64 官方下载。
最新版windows apache-tomcat-8.5.69-windows-x64.zip最新版windows apache-tomcat-8.5.69-windows-x64.zip
apache-tomcat-9.0.74-windows-x64
apache-tomcat-9.0.78-windows-x64
Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,版本tomcat-9.0.65。
Apache-tomcat-7.0.109-Windows-x64
最新版windows apache-tomcat-9.0.50-windows-x64.zip最新版windows apache-tomcat-9.0.50-windows-x64.zip
apache-tomcat-8.5.99-windows-x64
官方原版apache-tomcat-9.0.33-windows-x64.zip