用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - jsp代码库

submit

2017-10-24 作者:幽草举报

[jsp]代码库

<%@ page contentType="text/html; charset=UTF-8" import="java.io.*" %><%
 int i=0;
 String fileName="msgs/0.txt";
 request.setCharacterEncoding("gbk");
 File file=new File(fileName);
 File fileDir=new File("msgs");
 if (!(fileDir.exists()&&fileDir.isDirectory())) fileDir.mkdir();
 while (file.exists()) {
  i++;
  fileName="msgs/"+i+".txt";
  file=new File(fileName);
 }
 String thename=request.getParameter("thename");
 String emotion=request.getParameter("emotion");
 String target=request.getParameter("target");
 String color=request.getParameter("color");
 String myname=request.getParameter("myname");
 file.createNewFile();

 FileOutputStream oup=new FileOutputStream(file);
 OutputStreamWriter writer=new OutputStreamWriter(oup,"gbk");
 writer.append("N\r\n");

 writer.append(new String(request.getParameter("thename").getBytes("ISO-8859-1"),"UTF-8")+"\r\n");
 writer.append(new String(request.getParameter("emotion").getBytes("ISO-8859-1"),"UTF-8")+"\r\n");
 writer.append(new String(request.getParameter("target").getBytes("ISO-8859-1"),"UTF-8")+"\r\n");
 writer.append(new String(request.getParameter("color"))+"\r\n");
 writer.append(new String(request.getParameter("myname").getBytes("ISO-8859-1"),"UTF-8")+"\r\n"); 
 writer.close();

 /*
$.ajax({
    type: 'post',
    url: 'aaa/bbb.do',
    contentType: 'application/json;charset=utf-8',
    data: '{"name": "uname", "age": 18}',
    success: function (data) { //返回json结果
        alert(data);
    }
});
  */
 oup.close();
%><%out.print(true);%>


分享到:
更多

网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。