Jsp apache common fileupload 文件上传 乱码
在action里使用fileupload时,从reqeust得到的中文数据为乱码,尝试使用了
Java代码
1. DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("utf-8")
2.jsp文件的request.setCharacterEncoding("UTF-8");
3. FileItem item = (FileItem) itr.next();
String value = new String(item.getString().getBytes()) ;
均无效!
最终的解决办法是 使用 org.apache.commons.fileupload组件里的一个方法:
String value = new String(item.getString("UTF-8")
相关文档:
第一步:建立一个code.jsp的页面,产生随机码
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"
import="java.io.*,
java.util.*,
& ......
<tr>
<td height="30" align="right">域名:</td>
<td align="left"><input name="domain" type="text" class="input" value="<%=request.getServerName()%>"/></td>
<td align="left">系统已经检测出您的域名,请勿改动</td>
</t ......
<c:if>用于
流程控制
语法
1:
<c:if
test=”testCondition” var=”varName”
[scope=”page|request|session|application”]/>
语法
2:
<c:if
test=”testCondition” var=”varName”
[scope=&rdquo ......
一、概述
缓存的思想可以应用在软件分层的各个层面。它是一种内部机制,对外界而言,是不可感知的。
数据库本身有缓存,持久层也可以缓存。(比如:hibernate,还分1级和2级缓存)
业务层也可以有缓存(但一般来说,这是一个过程域,不会设缓存)。
&nbs ......