爱问知识人 爱问教育 医院库

这是它获得的是乱码还是中文,若果是乱码改怎样修改。

首页

这是它获得的是乱码还是中文,若果是乱码改怎样修改。

普通的java类获得从jsp页面传入的中文值,这是它获得的是乱码还是中文,若果是乱码改怎样修改。File f= new File(fileToZip[i]);
 tName()此时是乱码?  怎样修改。

fileToZip[i])是从jsp页面传入的,是中文文件名,包含了绝对地址。

提交回答

全部答案

    2011-06-16 14:09:26
  •   在web工程中,jsp页面上的请求时要进行字符编码转换的 通常在web。xml中添加过滤器作用是把request对象中的头信息参数等等进行编码转换 然后继续后续过滤链。
    web。xml加入 (尽可能考前排放 过滤器是有顺序的)
    	
    		Set Character Encoding
    		
    			 lter。
      SetCharacterEncodingFilter encoding GB18030 ignore true Set Character Encoding /* 下面要创建这个过滤器 上面配置中有个指定路径下的“ lter。
      SetCharacterEncodingFilter”当然你要换成你的包路径 //SetCharacterEncodingFilter过滤器java代码: package lter; import rvlet。Filter; import 。
      IOException; import rvlet。*; /** * @author longyue * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class SetCharacterEncodingFilter implements Filter { /** * The default character encoding to set for requests that pass through * this filter。
       */ protected String encoding = null; /** * The filter configuration object we are associated with。 If this value * is null, this filter instance is not currently configured。
       */ protected FilterConfig filterConfig = null; /** * Should a character encoding specified by the client be ignored? */ protected boolean ignore = true; // --------------------------------------------------------- Public Methods /** * Take this filter out of service。
       */ public void destroy() { this。encoding = null; lterConfig = null; } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (ignore || ( tCharacterEncoding() == null)) { String encoding = selectEncoding(request); if (encoding != null) { tCharacterEncoding(encoding); } } // Pass control on to the next filter Filter(request, response); } /** * Place this filter into service。
       * * @param filterConfig The filter configuration object */ public void init(FilterConfig filterConfig) throws ServletException { lterConfig = filterConfig; this。
      encoding = tInitParameter("encoding"); String value = tInitParameter("ignore"); if (value == null) { this。
      ignore = true; } else if (value。equalsIgnoreCase("true")) { this。ignore = true; } else if (value。
      equalsIgnoreCase("yes")) { this。ignore = true; } else { this。ignore = false; } } // ------------------------------------------------------ Protected Methods protected String selectEncoding(ServletRequest request) { return (this。
      encoding); } }。

    展***

    2011-06-16 14:09:26

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 180-199
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):