<%@ page pageEncoding="utf-8" %>
<HTML><BODY>
<P>选择要上传的文件:<BR>
<FORM action="accept.jsp" method="post" ENCTYPE="multipart/form-data">
<INPUT type=FILE name="boy" size="38">
<BR><INPUT type="submit" name="g" value="提交">
</FORM>
</BODY></HTML>
<%@ page pageEncoding="utf-8" %>
<%@ page import="java.io.*" %>
<HTML><BODY>
<%
try{ InputStream in=request.getInputStream();
File dir=new File("C:/1000");
dir.mkdir();
File f=new File(dir,"B.txt");
FileOutputStream o=new FileOutputStream(f);
byte b[]=new byte[1000];
int n;
while((n=in.read(b))!=-1)
o.write(b,0,n);
o.close();
in.close();
out.print("文件已上传");
}
catch(IOException ee){
out.print("上传失败"+ee);
}
%>
</BODY></HTML>
没有还是出现乱码
<%@ page pageEncoding="utf-8" %>
這一段的內容改為以下
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
就正常了