扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共19页)
<%@ page contentType="text/html; charset=GBK" %> <%@ taglib uri=ttp://java.sun.com/jsp/jstl/core prefix="c" %> <% Object str= request.getAttribute("user"); pageContext.setAttribute("user",str); %> <html> <head> <title> |
过滤器
</title> </head> <body bgcolor="#ffffff"> <h1> |
准备过滤
</h1> <h1>${pageScope.user}</h1> <form method="post" action="Example1.jsp"> <br> <input type="text" name="user" /> <br> <input type="submit" name="Submit" value="Submit"> <input type="reset" value="Reset"> </form> </body> </html> |
文字
<%@ page contentType="text/html; charset=GBK" %> import javax.servlet.*; public class Filter1 extends HttpServlet implements Filter { //Process the request/response pair try { if (user == null || user.equals("")) { } else { } //Clean up resources |
注:此“XML”代码是在运行时出现的,
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="ttp://java.sun.com/xml/ns/j2ee" xmlns:xsi="ttp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="ttp://java.sun.com/xml/ns/j2ee ttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>Web</display-name> <filter> <filter-name>filter1</filter-name> <filter-class>com.lgx.filtertext.dao.Filter1</filter-class> </filter> <filter-mapping> <filter-name>filter1</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <description>Added by JBuilder to compile JSPs with debug info</description> <servlet-name>debugjsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>classdebuginfo</param-name> <param-value>true</param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>debugjsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> </web-app> |
注:这一处代码是配置过滤器的,不过JBuilder2005里面Tomcat容器已自动配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="ttp://java.sun.com/xml/ns/j2e" xmlns:xsi="ttp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="ttp://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>Web</display-name> <filter> <filter-name>filter1</filter-name> <filter-class>com.lgx.filtertext.dao.Filter1</filter-class> </filter> <filter-mapping> <filter-name>filter1</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者