此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【benben525】截止到2008-07-09 08:53:47的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
楼主【benben525】截止到2008-07-09 08:53:47的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
解决方案 »
- 服务器端webservice更新后,客户端报java.lang.NoClassDefFoundError
- struts和hibernate整合无法得到SessionFactory
- mybatis传递参数问题
- 求解:关于JSTL的forEach嵌套循环之index不为零的问题,望高人指点
- JAVA
- 一个关于JFreeChart的问题
- 如何在hibernate中创建sequence?
- EJB的调用
- 有关j2ee的环境配置的问题,请高手指点!!急!!!!!!!!!!!
- 我的java基础还不错,但现在公司一说到java就会问你j2ee,我想去好好的学一下,请问哪里有这方面的资料和书籍。要学多久才有小成啊?
- 字符串比较
- http地址中的%问题
String a = new String(a.getByte("ISO-8859-1"),"GB2312");来处理一下啊
String a = new String(a.getByte("ISO-8859-1"),"gbk");
如果是utf-8就
String a = new String(a.getByte("ISO-8859-1"),"utf-8");
如果是gbk2312就
String a = new String(a.getByte("ISO-8859-1"),"gb2312");楼主还可用filter来做,这个比较彻底,一下子全转码了,google一大堆
你说的登录时候设置request.getSession(true).setAttribute("login", user);public class LoginFilter implements Filter{
public void doFilter( ServletRequest request ,ServletResponse response ,FilterChain chain )
throws ServletException ,IOException
{
HttpServletRequest req = (HttpServletRequest)request;
HttpSession session = req.getSession( true ) ;
Object obj = session.getAttribute( "login" ) ;
if( obj != null ){
chain.doFilter( request , response ) ;
}else{
HttpServletResponse res = (HttpServletResponse)response ;
res.sendRedirect( "login.jsp" ) ;
}}在web.xml中配置 XML code
<filter>
<filter-name>loginFilter</filter-name>
<filter-class>LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/*</url-pattern> <!--写你需要通过登陆才能访问的页面-->
</filter-mapping>
<filter>这样你在整个项目上需要登陆后才能访问的页面只需在web.xml中 <url-pattern> </url-pattern>指明就可以了
String a = new String(a.getByte("ISO-8859-1"),"gbk");
至于设定编码格式,也不能完全解释中文转码问题。
转成byte传入后台。看看可以不。
或者在web.xml中写过滤器
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
arg0.setCharacterEncoding("GBK");
arg2.doFilter(arg0, arg1);
}
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class FilterEncoding implements Filter {
private FilterConfig filterConfig=null;
private String encoding=null;
//初始化过滤器
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig=filterConfig;
this.encoding=filterConfig.getInitParameter("encoding");
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
String encoding=this.encoding;
if(encoding!=null)
{
//设置字符集
request.setCharacterEncoding(encoding);
}
chain.doFilter(request, response);
}
//过滤器销毁
public void destroy() {
this.encoding=null;
this.filterConfig=null;
}
}
<head>加上这句
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">