会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132359个问题
JAVA 全系列/第五阶段:JavaWeb开发/Ajax技术详解(旧) 422楼
JAVA 全系列/第五阶段:JavaWeb开发/XML技术(旧) 423楼

ServletDemon.rar

老师麻烦帮我看下为什么不能访问adduser.html

JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解 424楼

image.png

JAVA 全系列/第五阶段:JavaWeb开发/Web实战案例 426楼

老师,为啥我的控制台不答应监听相关的内容,我写了触发监听的代码,也配置了信息,当我请求的时候控制台没有反应

@WebServlet("/attr.do")
public class ServletContextAttrListenerServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = this.getServletContext();
        servletContext.setAttribute("key","itBz");
        servletContext.setAttribute("key","SxtIt");
        servletContext.removeAttribute("key");
    }
}
public class ServletContextAttrListener implements ServletContextAttributeListener {
    /**
     * 向ServletContext对象中添加属性时会触发该监听方法,并将
     * ServletContext对象传递到该方法中。触发事件的方法
     * servletContext.setAttribute("key","value")。
     * @param scae
     */
    @Override
    public void attributeAdded(ServletContextAttributeEvent scae) {
        System.out.println("------------------Start Added----------------------");
        System.out.println("name: "+scae.getName()+"value: "+scae.getValue());
        System.out.println(scae.getServletContext());
        System.out.println("------------------End Added----------------------");
    }


com.itbaizhan.listener.ServletContextAttrListener

image.png

JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解 428楼
JAVA 全系列/第五阶段:JavaWeb开发/Ajax技术详解(旧) 430楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解 433楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解 434楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637