解决JSP乱码的过滤器
----*web.xml *----
----*web.xml *----
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>cray.util.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
------------MyFilter.java-------------
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
public class MyFilter extends HttpServlet implements Filter
{
private FilterConfig filterConfig;
public void init(FilterConfig filterConfig) throws ServletException
{
this.filterConfig = filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain)
{
try
{
request.setCharacterEncoding("GBK");
filterChain.doFilter(request, response);
} catch (ServletException sx)
{
filterConfig.getServletContext().log(sx.getMessage());
} catch (IOException iox)
{
filterConfig.getServletContext().log(iox.getMessage());
}
}
public void destroy()
{
}
}
相关文档:
用的数据库是mysql
【第一种方式,用JSP实现】
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
//**************************************
& ......
以前用WSAD wizard做的,都可以在JSP页面中解析到EL表达式,当然前提是JSP2.0的情况下。
今天遇到了一个莫名其妙的问题。刚下载Eclipse3.3+MyEclipse6.0体验的过程中,遇上了解析不到EL表达式的问题。经过好几个小时的琢磨终于发现了,给大家share一下:
问题就出在建Web Project的时候web.xml声明上。
web.xml声明部 ......
jsp 缓存, html 缓存, ajax缓存,解决方法
url:http://blog.csdn.net/oklzh/archive/2009/08/14/4445722.aspx
有关页面缓存问题.这个问题上网找了好多.但发觉各种解决方法,都彼此分离,没有一篇统一的解决方法,本人近日,也遇到了页面缓存的问题,根据网上各页面缓存的解答,做了一个总结。
1.服务器端缓存的问题 ......
这个问题的确很烦人,其实都是MyEclipse的"自作聪明"和访问网络上的API Doc的结果(它默认用Visual Designer来打开的),进行下列设置即可有效缓解之。
1. 要么右键单击文件,选择 Open With -》 MyEclipse JSP Editor 打开,这样不会采用可视化的打开,耗资源少,自动提示也非常快。
2. 要么采取一劳永逸的方法 Window ......