package web1Pac;import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet
{ private static final long serialVersionUID = 1L;
private static final int doGetCount=0;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ response.setContentType("text/html;charset=utf-8");
PrintWriter out;
out=response.getWriter();
out.print("会家了");
System.out.println("doGetCount method called"+doGetCount+"times");
processRequest(request,response);
}
public void processRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{ PrintWriter out;
String title="Servlet Life Cycle Demo Page";
int iniCount=0;
int calledCount=0;
int destryCount=0;
String heading1="Init times"+iniCount;
String heading2="Called times"+calledCount;
String heading3="Destroy times"+destryCount;
response.setContentType("text/html;charset=utf-8");
out=response.getWriter();
out.print("<html><head><title>"+title+"<title>");
out.print("<head><body>");
out.print("<h1>"+heading1+"</h1>");
out.print("<h1>"+heading2+"</h1>");
out.print("<h1>"+heading3+"</h1>");
out.print("</body></html>");
out.close();
}
}
上面的程序使用的springsource软件编译的,启动服务器后,一会服务器端就会有输出doGetCount的值,而浏览器端却是空白,在doGet()中
调用自定义的processRequest(request,response)方法为什么没有用???怎样改才能够确保processRequest(request,response)调用了??
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet
{ private static final long serialVersionUID = 1L;
private static final int doGetCount=0;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ response.setContentType("text/html;charset=utf-8");
PrintWriter out;
out=response.getWriter();
out.print("会家了");
System.out.println("doGetCount method called"+doGetCount+"times");
processRequest(request,response);
}
public void processRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{ PrintWriter out;
String title="Servlet Life Cycle Demo Page";
int iniCount=0;
int calledCount=0;
int destryCount=0;
String heading1="Init times"+iniCount;
String heading2="Called times"+calledCount;
String heading3="Destroy times"+destryCount;
response.setContentType("text/html;charset=utf-8");
out=response.getWriter();
out.print("<html><head><title>"+title+"<title>");
out.print("<head><body>");
out.print("<h1>"+heading1+"</h1>");
out.print("<h1>"+heading2+"</h1>");
out.print("<h1>"+heading3+"</h1>");
out.print("</body></html>");
out.close();
}
}
上面的程序使用的springsource软件编译的,启动服务器后,一会服务器端就会有输出doGetCount的值,而浏览器端却是空白,在doGet()中
调用自定义的processRequest(request,response)方法为什么没有用???怎样改才能够确保processRequest(request,response)调用了??
解决方案 »
- JFileChooser的showOpenDialog文件打开选择框,怎么实现鼠标按键按住托选多个文件!!!!
- 火狐firebug查看源码
- cxf集成spring在tomcat5.5发布时候的问题
- 急求 Hibernate-extensions-2.1.3
- 哥哥:JSP 编译问题,快帮帮小妹吧!!!!
- 一个算法的问题!我觉得很难!看哪位大侠能作出来!
- jbuilder的困惑 郁闷啊
- 大侠们,帮个忙,小弟这里有些代码,但编绎时老是出提示!
- 请教一个问题,谢谢大家
- zdsxj2002(阿狗) ,baitianhai(hong) 接分
- struts2跳转问题
- 帮忙哇!SpringMVC 怎么才可以跟struts是的 把页面参数包装成实体类
去掉这段就可以了
out.print("<html><head><title>"+title+"<title>");
out.print("<head><body>");
out.print("<h1>"+heading1+"</h1>");
out.print("<h1>"+heading2+"</h1>");
out.print("<h1>"+heading3+"</h1>");
out.print("</body></html>");
都没加/加上肯定好了,注意点
public void destroy()
{ destryCount++;
System.out.println("destry method called"+destryCount+"times");
}这个方法在我停止服务器在从启服务器的时候没有在服务器窗口输出结果??