zoukankan      html  css  js  c++  java
  • filter原理

    index.jsp:

    <a href="product-input.action">input</a>

    <form action="product-save.action" method="post">
    ProductName:<input type="text" name="productName"/><br>
    productDesc:<input type="text" name="productDesc"/><br>
    productPrice:<input type="text" name="productPrice"/><br>
    <input type="submit" name="submit" value="submit">
    </form>

    details.jsp:

    productId:${product.productId}

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            // TODO Auto-generated method stub
            // place your code here
            HttpServletRequest req=(HttpServletRequest) request;
            String servletPath = req.getServletPath();
            System.out.println(servletPath);
            String path = null;
            if("/product-input.action".equals(servletPath)){
                path="/WEB-INF/pages/input.jsp";
            }
            if("/product-save.action".equals(servletPath)){
                String productName = request.getParameter("productName");
                String productDesc = request.getParameter("productDesc");
                String productPrice = request.getParameter("productPrice");
                Product product = new Product(null, productName, productDesc, productPrice);
                product.setProductId(1001);
                System.out.println(product);
                request.setAttribute("product", product);
                path = "/WEB-INF/pages/details.jsp";
            }
            if(path!=null){
                request.getRequestDispatcher(path).forward(request, response);
                return;
            }
            // pass the request along the filter chain
            chain.doFilter(request, response);
        }
    
    filterDispatcher
  • 相关阅读:
    每日站立会议08
    MAVEN常用命令
    android开发环境搭建
    阻止默认事件和阻止事件冒泡
    C#ActiveX安装项目
    System&Software
    poj 1386 Play on Words 有向欧拉回路
    poj 1033
    120.Triangle
    pandas中 transform 函数和 apply 函数的区别
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/6601865.html
Copyright © 2011-2022 走看看