猿问

servlet中用StringBuffer的方式输出一个表单输不出来而是输出我的项目名


public class Form extends HttpServlet {
 private static final long serialVersionUID = 1L;

    /**
     * Default constructor.
     */
    public Form() {
        // TODO Auto-generated constructor stub
    }

 /**
  * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  response.getWriter().append("Served at: ").append(request.getContextPath());
 }

 /**
  * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  response.setContentType("text/html;charset=utf-8");
  response.setCharacterEncoding("utf-8");
  PrintWriter writer = response.getWriter();
  StringBuffer buffer = new StringBuffer();
 /* <form action=''>
  username:<input type='text'>
  password:<input type='text'>
 </form> */
  buffer.append("<form action=''>");
  buffer.append("username:<input type='text'>");
  buffer.append("password:<input type='text'>");
  buffer.append("</form>");
 }

}

慕神4704991
浏览 1217回答 3
3回答

qq_LONELYPATIEN_33672566

先看你的http请求是什么类型
随时随地看视频慕课网APP

相关分类

Java
我要回答