• Web开发需要常见的问题


    1、sendRedirec()方法执行后,是会直接跳转到目标页面还是执行完其后的语句再跳转到目标页面???

      该方法在执行完其后面的语句才会跳转到目标页面,比如:

      public void doGet(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException{

        req.setCharacterEncoding("utf-8");

        String name = req.getParameter("userName");

        if(name==null || name.equals(" ")){

          resp.sendRedirec("input.jsp");

          return;  //调用return语句,结束doGet方法,避免后面的语句执行

        }

        PrintWriter out = resp.getWriter();

        out.println("hello");

      }

     2 在web.xml配置文件中有如下配置,Servlet容器会创建几个HelloServlet实例???

    <servlet>

      <servlet-name>hello_zh</servlet-name>

      <servlet-class>com.hzw.HelloServlet</servlet-class>

      <init-param>

        <param-name>language</param-name>

        <param-value>中文</param-value>

      </init-param>

      <init-param> 

        <param-name>mesage</param-name>

        <param-value>欢迎</param-value>

      </init-param>

          

    <servlet/>

    <servlet-mapping>

      <servlet-name>hello_zh</servlet-name>

      <url-pattern>/zh/hello</url-pattern>

    </servlet-mapping>

    <servlet>

      <servlet-name>hello_en</servlet-name>

      <servlet-class>com.hzw.HelloServlet</servlet-class>

      <init-param>

        <param-name>language</param-name>

        <param-value>English</param-value>

      </init-param>

      <init-param>  

        <param-name>mesage</param-name>

        <param-value>welcome</param-value>

      </init-param>

    <servlet/>

    <servlet-mapping>

      <servlet-name>hello_en</servlet-name>

      <url-pattern>/en/hello</url-pattern>

    </servlet-mapping>

     Servlet容器是根据web.xml配置文件中Servlet的数量来创建Servlet实例,而不管Servlet类是不是同一个

  • 相关阅读:
    virtual private catalog
    About Health Monitor Checks
    修改ORACLE-NLS_DATE_FORMAT时间格式的四种方式
    About Quick Packaging and Custom Packaging
    Fault Diagnosability Infrastructure Overview
    Basic Concepts of Block Media Recovery
    破解:前一刻觉得还有好多事要做,突然间就不知道该干什么了
    利用OSG实现模拟飞机尾迹-粒子系统
    解决电脑上PPT频繁刷新的问题
    如何查看自己电脑系统的安装日期-Window上
  • 原文地址:https://www.cnblogs.com/zwbg/p/5944094.html
Copyright © 2020-2023  润新知