"Java EE Enterprise Application Combat Learning record" Mygetattributelistener

Source: Internet
Author: User

1  PackageSanglp.servlet;2 3 ImportJavax.servlet.ServletContext;4 Importjavax.servlet.ServletContextAttributeEvent;5 ImportJavax.servlet.ServletContextAttributeListener;6 ImportJavax.servlet.annotation.WebListener;7 8 /**9 * Created by Administrator on 2016/10/5.Ten * Monitor the Listener of attribute changes within the ServletContext range One  */ A @WebListener -  Public classMyservletcontextattributelistenerImplementsServletcontextattributelistener { -  the @Override -      Public voidattributeadded (servletcontextattributeevent servletcontextattributeevent) { -ServletContext application=Servletcontextattributeevent.getservletcontext (); -         //get the added property name and property value +String name=servletcontextattributeevent.getname (); -Object value=Servletcontextattributeevent.getvalue (); +System.out.println (application+ "range added" +name+ "value for" +value+ "property"); A  at  -     } -  - @Override -      Public voidattributeremoved (servletcontextattributeevent servletcontextattributeevent) { -ServletContext application=Servletcontextattributeevent.getservletcontext (); in         //get the added property name and property value -String name=servletcontextattributeevent.getname (); toObject value=Servletcontextattributeevent.getvalue (); +System.out.println (application+ ") has removed the attribute" +name+ "with the value" +value+ "); -     } the  *  $ @OverridePanax Notoginseng      Public voidattributereplaced (servletcontextattributeevent servletcontextattributeevent) { -ServletContext application=Servletcontextattributeevent.getservletcontext (); the         //get the added property name and property value +String name=servletcontextattributeevent.getname (); AObject value=Servletcontextattributeevent.getvalue (); theSystem.out.println (application+ "Scope" replaced the "+name+" value for the "+value+" property "); +  -     } $}

"Java EE Enterprise Application Combat Learning record" Mygetattributelistener

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.