日期:2014-05-19  浏览次数:20682 次

ssh2整合乱码问题
我查看了数据库都是utf-8,myeclipse工作空间的也是utf-8,jsp也是utf-8,以及我的action也是utf-8的。可是为什么乱码?
最后我在web.xml中配置spring的过滤器,还是不行。最后把Tomact编码都改成utf-8了。可是存入数据库还是乱码
我在action输出了 输出的参数是乱码。
实在没有办法了!请问前辈们有木有什么办法啊!
jsp:
  <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
  <form action="foodAction!insert.action" method="get">
  <table>
  <tr>
  <td>食品的名称</td>
  <td><input type="text" name="food.name" value="" /></td>
  </tr>
  <tr>
  <td>食品的介绍</td>
  <td><input type="text" name="food.content" value="" /></td>
  </tr>
  <tr>
  <td>食品的价格</td>
  <td><input type="text" name="food.price" value="" /></td>
  </tr>
  </table>
  <input type="submit" value="提交">
  </form>
  </body>
</html>

web.xml:
  <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!--定义Spring的配置的位置,可以定义多个配置文件,可以使用通配符。 -->
<context-param>
<param-name>contextConLocationfig</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<!-- 监听spring的配置文件 启动项目加载spring配置文件 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<!-- Spring字符编码过滤器 -->
<filter>
<filter-name>CharsetFilter</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>
<filt