你好,我在我的项目中调用函数时遇到问题![在此处输入图像描述]
<form action="register" method="post">
<table>
<tr>
<td colspan="2" style="font-weight:bold;">UserID:</td><td><input type="text" name="Id"></td>
</tr>
<tr>
<td colspan="2" style="font-weight:bold;">Name :</td><td><input type="text" name="name"></td>
</tr>
<tr>
<td colspan="2" style="font-weight:bold;">Password</td><td><input type="password" name="pass"></td>
</tr>
<tr>
<td><input type="button" value="sumbitk"></td>
</tr>
</table>
</form>
<hr>
$
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
//RequestDispatcher dispatcher;
String id=req.getParameter("id");
String name=req.getParameter("name");
String password=req.getParameter("pass");
System.out.println("user id : "+id+" name "+name+" pass "+password);
resp.sendRedirect("/index.html");
//dispatcher=getServletContext().getRequestDispatcher("/index.html");
//dispatcher.forward(req, resp);
}
}
我在寄存器上进行了表单操作并调用了函数 post,但当我单击 sumbit 时它似乎不起作用,我不知道为什么。
最佳答案
首先尝试在最后一个输入中正确写入“提交”,如果不起作用,请尝试将最后一个输入的类型更改为“提交”而不是“按钮”
关于java - 如何使用 eclipse Google 应用引擎让 .jsp 调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28648352/