小编use*_*872的帖子

字符编码问题春天

我在网站上遇到编码的大问题!我使用spring 3,tomcat 6和mysql db.我想在我的网站上支持德语和捷克语以及英语,我将所有JSP创建为UTF-8文件,并在每个jsp中包含以下内容:

<%@ page language="java" contentType="text/html; charset=UTF-8"
     pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Run Code Online (Sandbox Code Playgroud)

我创建了messages.properties(默认为捷克语),messages_de.properties和messages_en.properties.所有这些都保存为UTF-8文件.

我在web.xml中添加了以下内容:

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

 <locale-encoding-mapping-list>
    <locale-encoding-mapping>
        <locale>en</locale>
        <encoding>UTF-8</encoding>
    </locale-encoding-mapping>
    <locale-encoding-mapping>
        <locale>cz</locale>
        <encoding>UTF-8</encoding>
    </locale-encoding-mapping>
    <locale-encoding-mapping>
        <locale>de</locale>
        <encoding>UTF-8</encoding>
    </locale-encoding-mapping>
</locale-encoding-mapping-list>

 <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
 </filter-mapping>  
Run Code Online (Sandbox Code Playgroud)

并将以下内容添加到我的applicationContext.xml中:

<bean id="messageSource"    
    class="org.springframework.context.support.ResourceBundleMessageSource"
    p:basenames="messages"/>

<!-- Declare the Interceptor -->
<mvc:interceptors>    
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
          p:paramName="locale" />
</mvc:interceptors>

<!-- Declare the Resolver -->
<bean id="localeResolver"  
       class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
Run Code Online (Sandbox Code Playgroud)

我在server.xml的元素中将useBodyEncodingForURI属性设置为true:%CATALINA_HOME%/ conf,另一次尝试添加URIEncoding ="UTF-8".

我使用charset [utf8]和集合[utf8_general_ci]创建了所有表和字段

我的浏览器中的编码是UTF-8(BTW,我有IE8和Firefox 3.6.3)

当我打开MYSQL查询浏览器并手动插入捷克语或德语数据时,它正确插入,并在我的应用程序中正确显示. …

spring tomcat character-encoding

13
推荐指数
1
解决办法
2万
查看次数

使用 PDFBox 进行图像旋转

我对使用 PDFBox 很陌生。我需要的是将带有旋转的图像添加到现有的 PDF 中!我知道如何添加图像,但我的问题是如何旋转图像!我看过一些关于 AffineTransform 和 Matrix 的东西,但我不知道那是什么以及它是如何工作的!

我真的很感激传递一些示例代码,并提前感谢您!

此致

image rotation pdfbox

5
推荐指数
1
解决办法
4022
查看次数

标签 统计

character-encoding ×1

image ×1

pdfbox ×1

rotation ×1

spring ×1

tomcat ×1