to 柳五公子:
呵呵,小弟试了一下,可是取不到参数呀。
源程序如下:
public class ItemServlet extends HttpServlet implements Serializable
{
public voiddo
Post(HttpServletRequest req, HttpServletResponse res)
{
service1(req, res);
}
public void service1(HttpServletRequest req, HttpServletResponse res) {
int contentLength = 0;
WriteFile dataParser = null;
contentLength = req.getContentLength();
try {
HttpUtils hu = new HttpUtils();
Hashtable hs = hu.parsePostData(contentLength,req.getInputStream());
dataParser = new WriteFile(hs,req,res);
} catch (Throwable ee) {
}
}
}
下面这个类是解析Hashtalbe的:
public class WriteFile
{
public WriteFile( Hashtable hs,HttpServletRequest req, HttpServletResponse res)
{
byte[] bBuf = new byte[4096];
int i;
try{
FileOutputStream FileOut = new FileOutputStream("test.txt");
FileInputStream FileIn = (FileInputStream)hs.get("File-01");
String info = ((String[])hs.get("T_1"))[0];
PrintWriter out = res.getWriter();
out.println(info);
i = FileIn.read(bBuf);
while (i != -1){
FileOut.write(bBuf);
i = FileIn.read(bBuf);
}
FileOut.flush();
FileOut.close();
}catch ( IOException e){
}
}
}
可是执行后,test.txt文件中是空的,response也没有把T_1的值回写给client,
大虾们,这是怎么回事呀?
呵呵。