public class MyServlet extends HttpServlet {
private static IUtils utils= null;
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
utils.do();
}
}
代码结构如上,do不是静态方法,且方法内使用的都是局部变量,做的事情就是连接数据库做查询,然后返回查询结果。
1.在doPost调用这个do方法是否安全?
2.是否有必要声明成静态的,我希望这个utils不要被反复创建。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
光阴似箭催人老,日月如移越少年。