日期:2014-05-18  浏览次数:20708 次

请问j2ee的目录架构是怎么样的?如何运行?
我的目录架构这样子对吗?


我想要运行form.html,再通过html的提交到HelloServlet.java这个servlet中,如何运行?

我的form.html:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<form action="hello.avi" method="post">
名称:<input type="text" name="user" /><br />
密码:<input type="password" name="passwd" /><br /><br />
<input type="submit" name="login" value="送出" />
</form>
</body>
</html>


HelloServlet.java:

package cc.openhome;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class HelloServlet
 */
@WebServlet(
name="Hello",
urlPatterns={"/hello.avi"},
loadOnStartup=1
)
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
    
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HelloServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
    @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletExceptionIOException {
// TODO Auto-generated method stub
     String body = readBody(request);
     PrintWriter out = response.getWriter();