日期:2014-05-18  浏览次数:20684 次

这些天遇到的几个问题,请大伙帮忙解答一下。
 
 1.我的页面在本地测试好好的,放到服务器上,所有的中文字都变成一个个调皮的问号,请问这个问题如何解决呢。
  页面我已设置为 "gbk"了。是不是服务器上要设置什么呀

 2.大家有没有遇到过,就是在本地测试的时候,有时刷新页面中文会变成一个个问题,再点刷新,又好了。请问
  这是不是因为我电脑缓存的问题呢。

 3.在本地测试的时候,在IE地址栏里面输入测试URL,如 http://localhost:8080/website/index.do 时,页面一片空白
  在MyEclipse 6.5会有这样的错误提示:19:39:54,859 ERROR [[action]] Servlet.service() for servlet action threw exception
java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2301)
at org.apache.catalina.connector.Request.getSession(Request.java:2075)
at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
  点刷新,又好了,请知道的朋友帮忙解答一下,不胜感激呀。
 

------解决方案--------------------
UP
------解决方案--------------------
乱码:写一个过滤器
报错:你创建session的顺序有问题,登陆时,先到登陆的jsp,之后在提交action
------解决方案--------------------
探讨
乱码:写一个过滤器
报错:你创建session的顺序有问题,登陆时,先到登陆的jsp,之后在提交action

------解决方案--------------------
试试2楼的方法。
------解决方案--------------------

------解决方案--------------------
服务器的encoding设置了么
------解决方案--------------------
学习了
------解决方案--------------------
过滤器。
新建包filter.,创建类 filterTest 实现javax.servlet.Filter接口
Java code

package filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class FilterTest implements Filter{

    public void destroy() {
        // TODO Auto-generated method stub
        
    }

    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        request.setCharacterEncoding("GBK");
        chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {
        // TODO Auto-generated method stub
        
    }
    
}

------解决方案--------------------
引用楼主 lovetxp 的帖子:

2.大家有没有遇到过,就是在本地测试的时候,有时刷新页面中文会变成一个个问题,再点刷新,又好了。请问
这是不是因为我电脑缓存的问题呢。

3.在本地测试的时候,在IE地址栏里面输入测试URL,如 http://localhost:8080/website/index.do 时,页面一片空白
在MyEclipse 6.5会有这样的错误提示:19:39:54,859 ERROR [[action]] Servlet.service() for servlet action threw exception