JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Object Relational Mapping » Hibernate  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Spring+Hibernate出现乱码
unser





發文: 26
積分: 0
於 2006-03-30 10:06 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
工程:Spring + Hibernate 3 + mysql 4.1
注意:应用程序,而不是Web Project

Spring的bean.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 
<beans>
  
  <!-- 数据库 -->
  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName">
      <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
      <value>jdbc:mysql://localhost:3306/javaworld</value>
    </property>
    <property name="username">
      <value>root</value>
    </property>
    <property name="password">
      <value>123456</value>
    </property>
  </bean>
  
  <!-- Hibernate -->
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
      <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
      </props>
    </property>
    <property name="mappingResources">
      <list>
        <value>javaworld.hbm.xml</value>
      </list>
    </property>
  </bean>
  
  <!-- 事务管理 -->
  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
      <ref local="sessionFactory" />
    </property>
  </bean>
  
  <!--  -->
  <bean id="mailDAO" class="Hibernate.MailImpl">
    <property name="sessionFactory">
      <ref local="sessionFactory" />
    </property>
  </bean>
  
  
  <bean id="mailDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
      <ref bean="transactionManager" />
    </property>
    <property name="target">
      <ref local="mailDAO" />
    </property>
    <property name="transactionAttributes">
      <props>
        <prop key="insert*">PROPAGATION_REQUIRED</prop>
        <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
        <prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
      </props>
    </property>
  </bean>
  
</beans>


以上的配置文件会出现乱码问题,如果我将url写成:jdbc:mysql://localhost:3306/javaworld?useUnicode=true&characterEncoding=GBK&autoReconnect=true
就会出现xml加载出错,请问要如何处理乱码问题?


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
1857 Spring+Hibernate出现乱码 unser 2306 2006-03-30 10:06
1487 Re:Spring+Hibernate出现乱码 koji 99 2006-03-30 11:08
1508 Re:Spring+Hibernate出现乱码 unser 24 2006-03-30 11:27
1503 Re:Spring+Hibernate出现乱码 unser 274 2006-03-30 11:34
1452 Re:Spring+Hibernate出现乱码 koji 427 2006-03-30 11:55
1434 Re:Spring+Hibernate出现乱码 ncowboy 269 2006-03-30 12:41
1447 Re:Spring+Hibernate出现乱码 ncowboy 557 2006-03-30 12:43
1511 Re:Spring+Hibernate出现乱码 unser 56 2006-03-30 12:56
1596 Re:Spring+Hibernate出现乱码 unser 32 2006-03-30 14:20
» JWorld@TW »  Object Relational Mapping » Hibernate

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8