我正在尝试使用googleappengine
在浏览器上运行网络应用。我的代码如下。我想做的只是通过html提供的任何输入,它应该在servlet上接收并再次在浏览器上显示。
public class TestServerServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
try{
String name= req.getParameter("name");
String msg = req.getParameter("message");
resp.setContentType("text/plain");
resp.getWriter().println("user name is"+name);
}catch(Exception e)
{
System.err.println(e);
}
}
}
的index.html:
<html>
<head>
<meta charset="ISO-8859-1">
<title>Submission Form</title>
</head>
<body>
<from method="POST" action ="TestServer">
Mail id: <input type ="text" name ="name"/><br/>
Message: <input type ="text" name ="message"/><br>
<input type="submit" value="Submit" />
</from>
</body>
</html>
的web.xml:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>TestServer</servlet-name>
<servlet-class>com.example.test.TestServerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServer</servlet-name>
<url-pattern>/testserver</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
因此,当我使用http://localhost:8088/index.html
在浏览器上运行时,会显示html表单,但我无法查看输出。有人可以建议我哪里出错了吗?