servlet类中throws抛出异常出错?

package servlet;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.GenericServlet;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;


public class ServletSample extends GenericServlet {


public void service(ServletRequest request,ServletResponse response){

    throws ServletException,IOException  {

        response.setCharacterEncoding("gbk");

        PrintWriter out=response.getWriter();

        out.println("<html>");

        out.println("head");

        out.println("<title>简单的例子</title>");

        out.print("</head>");

        out.println("<body>");

        out.println("<center>");

        out.println("<h2>这是第一个servlet的例子</h2>");

        out.println("</center>");

        out.print("</body>");

        out.println("</html>");

        out.close();

    }

}

}

https://img1.mukewang.com/5cb689ca0001358907490562.jpg

帮帮忙,我是初学者,请多多指教,谢谢

PIPIONE
浏览 670回答 1
1回答

眼眸繁星

多了一组大括号
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java