bean:include 乱码问题
请牛人帮忙看看这个问题:
我在index.jsp中有引用一个页面:
<bean:include id="catalogs" page="listCatalog.do" /><bean:write name="catalogs" filter="false" /> 但是发现listCatalog.do中的内容在页面中显示为乱码。如果单独运行listCatalog.do就不会出现这种情况。或者把listCatalog.do指向的页面的contentType改为GB2312时,在index.jsp中也能够正确显示。
其中
1、 index.jsp和listCatalog.dol两个页面都定义了:<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
listCatalog.do指向的页面中写数据的语句:<bean:write name="catalogs" property="name"/>
2、我mysql数据库、用的是utf-8格式、
3、连接串:jdbc:mysql://localhost:3308/gydb?useUnicode=true&characterEncoding=UTF-8
4、web.xml中encoding定义为UTF-8
5、我在filter中定义了转换utf-8字符集:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
if(ignore || request.getCharacterEncoding() == null)
{
String encoding = selectEncoding(request);
if(encoding != null)
{
request.setCharacterEncoding(encoding);
}
}
chain.doFilter(request, response);
}
最后为什么我用bean:include引用这个action的时候显示的内容就是乱码?而单独执行这个action时候就显示正常。我应该怎么办?
我已经在几个论坛发过贴子了,都没答案,但愿csdn有牛人能够帮我解答。