<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource
name="jdbc/huodong"
auth="Container"
type="javax.sql.DataSource"
maxActive="5"
maxIdle="3"
username="root"
maxWait="180"
driverClassName="org.gjt.mm.mysql.Driver"
password=""
url="jdbc:mysql://localhost:3306/myDb?useUnicode=true&characterEncoding=GBK"
removeAbandoned="true" removeAbandonedTimeout="5" logAbandoned="true"
testOnReturn="true" testWhileIdle="true"/>
</GlobalNamingResources>
注意:url="jdbc:mysql://localhost:3306/myDb?useUnicode=true&characterEncoding=GBK"
不要写成:url="jdbc:mysql://localhost:3306/myDb?useUnicode=true&characterEncoding=GBK"
注意:& 是& 的转义字符;在xml中写成上面那个,在java代码中写成下面的写法;
否则报:
Parse Fatal Error at line 213 column 91: The reference to entity "characterEncoding" must end with the ';' delimiter.
org.xml.sax.SAXParseException: The reference to entity "characterEncoding" must
end with the ';' delimiter.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
known Source)
还要在tomcat的 conf/server.xml 中修改如下类容:
<Connector port="80" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK"/>
红色部分是添加的类容
分享到:
相关推荐
润乾报表乱码问题尤其令人头疼,因为它影响了数据的显示和传输,尤其是对于汉字而言,乱码使得数据几乎无法阅读和使用。 首先,报表乱码问题分为多种类型,包括页面显示乱码、导出文件乱码和参数乱码。页面显示乱码...
当数据库中存储的内容正确无误,但在前端展示时汉字显示为乱码。 **原因:** 主要原因是数据库取出的数据在传输到前端展示的过程中未进行正确的字符集转换。 **解决方法:** 1. **调整数据源配置:** - 在`WEB-...
3. 在应用的上下文中,通过JNDI查找并获取数据源,如: ```java Context initCtx = new InitialContext(); DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/mydb"); Connection conn = ds.get...
由于提供的【部分内容】中包含一些乱码和重复的文字,可能是因为OCR扫描技术原因所致,以下是根据您提供的文档内容所提炼的Java相关知识点: ### Servlet技术 Servlet是Java EE技术中用于扩展服务器功能的核心组件...
- **处理汉字信息**:使用setCharacterEncoding()方法设置字符编码,解决中文乱码问题。 - **常用方法举例**:如getHeader()、getSession()等,用于获取请求头信息或会话对象。 ##### 3.2 response对象 - **动态...
role 否 String 是 Role 的名称,如: role=”tomcat” 就允许当前用户角色为 tomcat 的访问该控件, role=”!tomcat” 则就允许除角色为 tomcat 以外的所有的用户访问。 query 是 OlapModel 是 一个 ...