发表于: 2017-09-20 20:37:19

2 759


禅道:http://task.ptteng.com/zentao/project-task-302.html

今天完成的事情:

完成任务7的最后
这是用志勇的最后的类转义的。
贴一下代码
//打开文件选择对话框
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFileChooser fileChooser = new JFileChooser();
fileChooser.showOpenDialog(null);
String filePath = "" + fileChooser.getSelectedFile();
String fileName = "" + fileChooser.getSelectedFile().getName();
System.out.println("选择文件路径: " + filePath);
System.out.println("选择文件的文件名: " + fileName);
String newURL = filePath.replaceAll("\\\\", "/");
System.out.println("转义后的文件路径:" + newURL);
然后下面是正常的上传文件的类了。之前日报贴过,是能正常上传的。
然后短信找了个随机数的
Integer heihei = (int)((Math.random()*9+1)*100000);
String suiji=heihei.toString();
再把他转成string
然后验证的时候就是把生成的提交上去,在弄下来看想不想等
HttpSession session = request.getSession();
session.setAttribute("suiji",suiji);
public String zhuce(User4 user4,String xy,HttpServletRequest request){
    HttpSession session = request.getSession();
    String suiji = (String) session.getAttribute("suiji");
    if(xy.equals(suiji)) {

 相等的话就让注册,不相等就不让注册。明天吧任务7提交了。


@responseBody注解的使用
1、
  @responseBody注解的作用是将controller的方法返回的对象通过适当的转换器转换为指定的格式之后,写入到response对象的body区,通常用来返回JSON数据或者是XML
  数据,需要注意的呢,在使用此注解之后不会再走试图处理器,而是直接将数据写入到输入流中,他的效果等同于通过response对象输出指定格式的数据。
2、
  @RequestMapping("/login")
  @ResponseBody
  public User login(User user){
    return user;
  }
  User字段:userName pwd
  那么在前台接收到的数据为:'{"userName":"xxx","pwd":"xxx"}'
  效果等同于如下代码:
  @RequestMapping("/login")
  public void login(User user, HttpServletResponse response){
    response.getWriter.write(JSONObject.fromObject(user).toString());
  }


明天的计划:提交任务7 师兄明天帮我审核一下进行任务8


返回列表 返回列表
评论

    分享到