Springside Development (II.): modifying databases, character encodings, and rapid deployment applications

Source: Internet
Author: User
Tags filter config i18n

Springside The default database is Hsql, but the database that most developers are familiar with is MySQL, so the first thing you encounter in the actual development process is to modify the database. It is easy to modify the database in Springside, or as an example of a Xkland project created in the previous article, first modify the Jdbc.properties file under the Src\main\resources\config folder, comment out 1, 2 lines, and annotate 7, 8 lines, and modify the username and password for lines 10 and 11 as follows:

1#jdbc.driverClassName=org.hsqldb.jdbcDriver
2#jdbc.url=jdbc:hsqldb:res:/hsqldb/helloworld
3
4#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
5#jdbc.url=jdbc:oracle:thin:@localhost:helloworld
6
7jdbc.driverClassName=com.mysql.jdbc.Driver
8jdbc.url=jdbc:mysql://localhost:3306/xkland? useUnicode=true&characterEncoding=utf8
9
10jdbc.username=xkland
11jdbc.password=xkland

The second is to modify the Hibernate.properties file under the Src\main\resources\config folder, comment out the first line, and annotate the second line, as follows:

1#hibernate.dialect=org.hibernate.dialect.HSQLDialect
2hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
3#hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
4hibernate.show_sql=false
5hibernate.cache.use_query_cache=true
6hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider

The process is simple, but there is one important thing to note, and that is to remember to copy the JDBC-driven mysql.jar provided by MySQL to the Src\main\webapp\web-inf\lib folder, otherwise you will encounter the following error:

Springside is very focused on support for i18n, so it's convenient to create an internationalized application, just add the appropriate resource file to the src\mian\resources\i18n folder. Springside default use of UTF-8 encoding, which is registered from the Web.xml Encodingfilter can be seen, of course, can also choose their favorite character encoding, such as GB2312. If you want to modify the character encoding, be sure to remember that there are four places to keep in line:

1, Web.xml in the Encodingfilter configuration, as follows:

<filter>
    <filter-name>encodingFilter</filter-name>
     <filter- class>org.springframework.web.filter.CharacterEncodingFilter</filter- class>
     <init-param>
       <param-name>encoding</param-name>
       <param-value>UTF-8</param-value>
     </init-param>
</filter>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.