zoukankan      html  css  js  c++  java
  • ajax servlet端小问题

    说是小问题。。。调试了一天气死了

    代码
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String username
    = request.getParameter("username");
    String password
    = request.getParameter("password");
    response.setContentType(
    "text/html;utf-8");
    response.setCharacterEncoding(
    "utf-8");
    PrintWriter writer
    = response.getWriter();

    if(null != username && null != password) {
    if(username.equals("") || password.equals("")) {
    writer.println(
    "don't post empty value");
    }
    else {

    if(username.equalsIgnoreCase("xc") && password.equalsIgnoreCase("123")) {
    writer.println(
    "ok");
    }
    else {
    writer.println(
    "error");
    }
    }
    response.flushBuffer();
    }
    }

    很简单的提交,返回

    ok后面直接多了个%0D%0A,

    今天才知道,println啊…………………………

    全部改成print就对了。。。

  • 相关阅读:
    Design Pattern Explained
    StringBuilder or StringBuffer
    Algorithms
    Difference between pages and blocks
    Date Time Calendar
    Math if fun
    Sublime Text
    Java Regex
    Learning C
    跨域通信/跨域上传浅析
  • 原文地址:https://www.cnblogs.com/xiziyin/p/1639420.html
Copyright © 2011-2022 走看看