filter原理
2024-08-24 22:06:09
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
最新文章
- 总结30个CSS3选择器
- 【转载】Java集合类Array、List、Map区别和联系
- Facebook 的系统架构(转)
- ORACLE 对用户密码做限制
- 《head first java 》读书笔记(五)
- HDU1398Square Coins(母函数)
- SGU 134.Centroid(图心)
- HYSBZ 2818 gcd
- 【LigerUI】ajax请求firefox返回NS_BINDING_ABORTED
- 基于visual Studio2013解决C语言竞赛题之0904文件排序
- 芝麻HTTP:Python爬虫进阶之Scrapy框架安装配置
- MySQL中的数值函数
- set 数据类型
- tool 使用font-spider解决字体压缩问题
- [luogu3377][左偏树(可并堆)]
- xshell无法在小键盘输入数字
- view之Scroller工具类和GestureDetector的简单用法
- mysql网课部分笔记
- ZOJ3180 Number Game
- 转载、Python的编码处理(二)