第一步:在idea下建一个javaWEB工程;
第二步:新建一个工程,不需要在web下写些前端,因为想在HBuild中写前端;
第三步:在controller包下新建一个servlet,我这里命名叫Servlet1,代码如下:
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); String name=request.getParameter("name"); System.out.println(name); PrintWriter out = response.getWriter(); try{ out.write(name); out.flush(); }catch (Exception e){ e.printStackTrace(); }finally { out.close(); } }
第三步:打开HBuilder编辑器,新建一个html项目,
index2.html的代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="