0

I have implemented a basic spring mvc form. Now, it is able to read special characters like @#$%^&* but there are few things which is missing like, if I type "..........", it reads it as something like "?.." or it is not reading text between < and > characters. I googled out to find out the solution and so it seems that spring mvc by default do not follow UTF-8 pattern. So, I appended the following code in web.xml

           <filter>
   <filter-name>springCharacterEncodingFilter</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>
  <init-param>
      <param-name>forceEncoding</param-name>
    <param-value>true</param-value>
  </init-param>
  </filter>

I am using

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

in my page. Also, in my server.xml I am using

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>

But the problem is still there. Can anyone suggest me what I am missing out or there is any other cause of the problem?

4

1 回答 1

2

我终于得到了解决方案......你需要使用

    <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="ISO-8859-1"%>

代替

   <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

在您的 jsp 文件中。

于 2013-11-27T14:10:46.797 回答