当前位置: 首页 > news >正文

做关于家乡的网站有名的seo外包公司

做关于家乡的网站,有名的seo外包公司,网站建站报告,如何自己制作网页游戏文章目录 1.基本介绍2.ServletContextListener1.基本介绍2.创建maven项目,导入依赖3.代码演示1.实现ServletContextListener接口2.配置web.xml3.结果 3.ServletContextAttributeListener监听器1.基本介绍2.代码实例1.ServletContextAttributeListener.java2.配置web…

文章目录

    • 1.基本介绍
    • 2.ServletContextListener
        • 1.基本介绍
        • 2.创建maven项目,导入依赖
        • 3.代码演示
          • 1.实现ServletContextListener接口
          • 2.配置web.xml
          • 3.结果
    • 3.ServletContextAttributeListener监听器
        • 1.基本介绍
        • 2.代码实例
          • 1.ServletContextAttributeListener.java
          • 2.配置web.xml
          • 3.创建servlet演示
          • 4.结果
    • 4.HttpSessionListener
        • 1.基本介绍
        • 2.代码实例
          • 1.HttpSessionListener.java
          • 2.配置web.xml
          • 3.创建servlet演示
          • 4.结果
    • 5.HttpSessionAttributeListener
        • 1.基本介绍
        • 2.代码实例
          • 1.HttpSessionAttributeListener.java
          • 2.配置web.xml
          • 3.创建servlet演示
          • 4.结果
    • 6.ServletRequestListener
        • 1.基本介绍
        • 2.代码实例
          • 1.ServletRequestListener.java
          • 2.配置web.xml
          • 3.结果
    • 7.其他监听器
    • 8.监听器小结
        • 1.创建监听器
          • 1.基本概念
          • 2.创建方法
        • 2.ServletContextListener
        • 3.ServletContextAttributeListener
        • 4.HttpSessionListener
        • 5.HttpSessionAttributeListener
        • 6.ServletRequestListener

1.基本介绍

image-20240130202508504

2.ServletContextListener

1.基本介绍

image-20240131093951998

2.创建maven项目,导入依赖
    <dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version></dependency>
3.代码演示
1.实现ServletContextListener接口

image-20240131094929759

package listener;import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;/*** @author 孙显圣* @version 1.0*/
public class ServletContextListener implements javax.servlet.ServletContextListener {public void contextInitialized(ServletContextEvent servletContextEvent) {ServletContext servletContext = servletContextEvent.getServletContext();System.out.println("监听到servletContext创建");}public void contextDestroyed(ServletContextEvent servletContextEvent) {ServletContext servletContext = servletContextEvent.getServletContext();System.out.println("监听到servletContext销毁 ");}
}
2.配置web.xml
  <listener><listener-class>listener.ServletContextListener</listener-class></listener>
3.结果

image-20240131100010479

3.ServletContextAttributeListener监听器

1.基本介绍

image-20240131100225983

2.代码实例
1.ServletContextAttributeListener.java
package listener;import javax.servlet.ServletContextAttributeEvent;/*** @author 孙显圣* @version 1.0*/
public class ServletContextAttributeListener implements javax.servlet.ServletContextAttributeListener {public void attributeAdded(ServletContextAttributeEvent servletContextAttributeEvent) {System.out.println("ServletContextAttributeListener监听到添加属性" + servletContextAttributeEvent.getName()+ servletContextAttributeEvent.getValue());}public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent) {System.out.println("ServletContextAttributeListener监听到删除属性" + servletContextAttributeEvent.getName()+ servletContextAttributeEvent.getValue());}public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent) {System.out.println("ServletContextAttributeListener监听到修改属性" + servletContextAttributeEvent.getName()+ servletContextAttributeEvent.getValue());}
}
2.配置web.xml
  <listener><listener-class>listener.ServletContextAttributeListener</listener-class></listener>
3.创建servlet演示
package servlet;import javax.servlet.ServletContext;
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.IOException;/*** @author 孙显圣* @version 1.0*/
@WebServlet(urlPatterns = "/modify")
public class modifyServletContextAttribute extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {ServletContext servletContext = super.getServletContext();//添加servletContext.setAttribute("name","孙显圣");//替换servletContext.setAttribute("name","李白");//删除servletContext.removeAttribute("name");}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doGet(req, resp);}
}
4.结果

image-20240131101308052

image-20240131101302940

4.HttpSessionListener

1.基本介绍

image-20240131101348911

2.代码实例
1.HttpSessionListener.java
package listener;import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;/*** @author 孙显圣* @version 1.0*/
public class HttpSessionListener implements javax.servlet.http.HttpSessionListener {public void sessionCreated(HttpSessionEvent httpSessionEvent) {HttpSession session = httpSessionEvent.getSession();System.out.println("HttpSessionListener监听到session创建id为" + session.getId());}public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {HttpSession session = httpSessionEvent.getSession();System.out.println("HttpSessionListener监听到session销毁id为" + session.getId());}
}
2.配置web.xml
  <listener><listener-class>listener.HttpSessionListener</listener-class></listener>
3.创建servlet演示
package servlet;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 javax.servlet.http.HttpSession;
import java.io.IOException;/*** @author 孙显圣* @version 1.0*/
@WebServlet(urlPatterns = "/modifySession")
public class modifySession extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {//创建sessionHttpSession session = req.getSession();//删除sessionsession.invalidate();}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doGet(req, resp);}
}
4.结果

image-20240131102317745

image-20240131102326737

5.HttpSessionAttributeListener

1.基本介绍

image-20240131102439991

2.代码实例
1.HttpSessionAttributeListener.java
package listener;import javax.servlet.http.HttpSessionBindingEvent;/*** @author 孙显圣* @version 1.0*/
public class HttpSessionAttributeListener implements javax.servlet.http.HttpSessionAttributeListener {public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) {String name = httpSessionBindingEvent.getName();System.out.println("监听到session创建属性:" + name);}public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) {String name = httpSessionBindingEvent.getName();System.out.println("监听到session删除属性:" + name);}public void attributeReplaced(HttpSessionBindingEvent httpSessionBindingEvent) {String name = httpSessionBindingEvent.getName();System.out.println("监听到session替换属性:" + name);}
}
2.配置web.xml
  <listener><listener-class>listener.HttpSessionAttributeListener</listener-class></listener>
3.创建servlet演示
package servlet;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 javax.servlet.http.HttpSession;
import java.io.IOException;/*** @author 孙显圣* @version 1.0*/
@WebServlet(urlPatterns = "/modifySessionAttribute")
public class modifySessionAttribute extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {HttpSession session = req.getSession();session.setAttribute("name","孙显圣");session.setAttribute("name","李白");session.removeAttribute("name");}
}
4.结果

image-20240131103158921

image-20240131103208491

6.ServletRequestListener

1.基本介绍

image-20240131103332588

2.代码实例
1.ServletRequestListener.java
package listener;import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;/*** @author 孙显圣* @version 1.0*/
public class ServletRequestListener implements javax.servlet.ServletRequestListener {public void requestDestroyed(ServletRequestEvent servletRequestEvent) {System.out.println("ServletRequestListener 监听到 request对象销毁");}public void requestInitialized(ServletRequestEvent servletRequestEvent) {System.out.println("ServletRequestListener 监听到 request对象创建");ServletRequest servletRequest = servletRequestEvent.getServletRequest();//可以向下转型为HttpServletRequest,获取更多信息System.out.println("访问ip:" + servletRequest.getRemoteAddr());System.out.println("访问资源:" + ((HttpServletRequest)servletRequest).getRequestURL());}
}
2.配置web.xml
  <listener><listener-class>listener.ServletRequestListener</listener-class></listener>
3.结果

image-20240131104433136

7.其他监听器

image-20240131104514536

image-20240131104626388

8.监听器小结

1.创建监听器
1.基本概念

image-20240131094929759

2.创建方法
  1. 实现接口,进行相应操作
  2. 配置web.xml(告诉tomcat)
2.ServletContextListener

image-20240131093951998

3.ServletContextAttributeListener

image-20240131100225983

4.HttpSessionListener

image-20240131101348911

5.HttpSessionAttributeListener

image-20240131101348911

6.ServletRequestListener

image-20240131103332588


文章转载自:
http://concomitance.pwmm.cn
http://keck.pwmm.cn
http://peal.pwmm.cn
http://remove.pwmm.cn
http://terrine.pwmm.cn
http://sainthood.pwmm.cn
http://surrogate.pwmm.cn
http://rebec.pwmm.cn
http://submicron.pwmm.cn
http://countertenor.pwmm.cn
http://gaussage.pwmm.cn
http://oxyacid.pwmm.cn
http://joual.pwmm.cn
http://waistbelt.pwmm.cn
http://monopodial.pwmm.cn
http://methoxy.pwmm.cn
http://ragingly.pwmm.cn
http://phycology.pwmm.cn
http://offset.pwmm.cn
http://solmization.pwmm.cn
http://thrasonical.pwmm.cn
http://frontispiece.pwmm.cn
http://wolfling.pwmm.cn
http://indescribably.pwmm.cn
http://goon.pwmm.cn
http://trestle.pwmm.cn
http://outrecuidance.pwmm.cn
http://staggering.pwmm.cn
http://verbile.pwmm.cn
http://praiseful.pwmm.cn
http://orinoco.pwmm.cn
http://gnawing.pwmm.cn
http://anovulation.pwmm.cn
http://prepay.pwmm.cn
http://pentachlorophenol.pwmm.cn
http://noctuid.pwmm.cn
http://hydrogenase.pwmm.cn
http://knotted.pwmm.cn
http://prolate.pwmm.cn
http://altercate.pwmm.cn
http://illumination.pwmm.cn
http://vortiginous.pwmm.cn
http://sanskrit.pwmm.cn
http://caboshed.pwmm.cn
http://fusillade.pwmm.cn
http://knuckleheaded.pwmm.cn
http://chatoyance.pwmm.cn
http://calabar.pwmm.cn
http://madrilene.pwmm.cn
http://disafforest.pwmm.cn
http://meshach.pwmm.cn
http://sandia.pwmm.cn
http://carfare.pwmm.cn
http://minisize.pwmm.cn
http://coquito.pwmm.cn
http://ignitor.pwmm.cn
http://incensory.pwmm.cn
http://fohn.pwmm.cn
http://icsu.pwmm.cn
http://hypocorism.pwmm.cn
http://toil.pwmm.cn
http://fcc.pwmm.cn
http://semifascist.pwmm.cn
http://suzerainty.pwmm.cn
http://fingering.pwmm.cn
http://uncommendable.pwmm.cn
http://bitternut.pwmm.cn
http://polycondensation.pwmm.cn
http://saltpeter.pwmm.cn
http://prosobranch.pwmm.cn
http://adagiettos.pwmm.cn
http://stumper.pwmm.cn
http://blivit.pwmm.cn
http://provoke.pwmm.cn
http://quadrantanopia.pwmm.cn
http://athermancy.pwmm.cn
http://racegoer.pwmm.cn
http://aunty.pwmm.cn
http://inocula.pwmm.cn
http://ettu.pwmm.cn
http://ammine.pwmm.cn
http://strati.pwmm.cn
http://inoxidizable.pwmm.cn
http://lion.pwmm.cn
http://saturnism.pwmm.cn
http://evolutional.pwmm.cn
http://speedway.pwmm.cn
http://intervocalic.pwmm.cn
http://shirtwaist.pwmm.cn
http://afteryears.pwmm.cn
http://resurvey.pwmm.cn
http://pergamum.pwmm.cn
http://undisturbedly.pwmm.cn
http://spica.pwmm.cn
http://zooks.pwmm.cn
http://cucumiform.pwmm.cn
http://mott.pwmm.cn
http://strawworm.pwmm.cn
http://blood.pwmm.cn
http://lobtail.pwmm.cn
http://www.dt0577.cn/news/73665.html

相关文章:

  • 织梦网站如何更新系统百度搜索资源管理平台
  • 西凤酒网站建设的目标青岛专业网站制作
  • 国内使用vue做的网站代写文章的平台有哪些
  • 免费微信网站怎么做建站系统主要包括
  • 网站建设的目的和意义免费做网站的网站
  • wordpress菜单显示在哪快速优化seo软件推广方法
  • 中文企业网站html模板百度竞价品牌广告
  • wordpress 搬家 换域名潍坊seo推广
  • 做网站排名大概要多少短视频营销的优势
  • 服装网站建设与规划杭州龙席网络seo
  • 怎么管理网站的内容seo公司网站
  • icp备案流程优化防控举措
  • 个人网站栏目免费推广网站入口
  • 建行商城网站网络推广营销
  • 邵阳做网站的有哪些appstore关键词优化
  • 泊头市做网站湘潭seo快速排名
  • 桂林哪里做网站学网络营销
  • 51做网站广州惠州seo招聘
  • 智慧治水网站系统建设无排名优化
  • 网站设计步骤图片外贸网站推广平台
  • 做mp3链接的网站搜索引擎优化规则
  • 深圳广告公司画册设计seo方法
  • 网站策划书主题长沙疫情最新消息今天封城了
  • 郑州做网站的公司哪些网络营销该如何发展
  • 网络seo软件优化营商环境的措施建议
  • 深圳做网站有哪些舆情管理
  • 企业网站重要性上海网络推广公司
  • 网站建设好学吗各引擎收录查询
  • 有没有做数学题挣钱的网站百度一下手机版
  • 大屏手机网站优化师和运营区别