Servlet给出空白输出

时间:2014-02-09 06:20:25

标签: servlets

我正在使用apache-tomcat-7.0.47。我创建了一个Java文件,如下所示

C:\Program Files\apache-tomcat-7.0.47\webapps\Portal\WEB-INF\classes

LoginCheck.java

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ResourceBundle;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginCheck extends HttpServlet {
    //private static final long serialVersionUID = 1L;
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        ResourceBundle rb =
            ResourceBundle.getBundle("LocalStrings",request.getLocale());
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<head>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Hello1</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

web.xml如下

C:\Program Files\apache-tomcat-7.0.47\webapps\Portal\WEB-INF

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
    <servlet-name>LoginCheck</servlet-name>
    <servlet-class>LoginCheck</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>LoginCheck</servlet-name>
    <url-pattern>/LoginCheck</url-pattern>
</servlet-mapping>
</web-app>

我在浏览器中使用URL访问上述内容时

localhost:8080/Portal/LoginCheck

我只是空白屏幕。

帮帮我们......

0 个答案:

没有答案