當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
html模板(base标签,meta标签,禁用浏览器缓存)+JSP自定义标签荔枝
生活随笔
收集整理的這篇文章主要介紹了
html模板(base标签,meta标签,禁用浏览器缓存)+JSP自定义标签荔枝
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
【1】html模板
<html> <head><!-- base標(biāo)簽表示uri相對(duì)路徑的基準(zhǔn)路徑 --><base href="http://localhost:8080/asite6/chapter6/ex6_11/visitor.html"/><title>html template</title><!-- meta 模擬響應(yīng)消息頭:Content-Type 表示內(nèi)容類型 --> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><!-- meta 模擬響應(yīng)消息頭:下面3個(gè)響應(yīng)頭都是為了禁用瀏覽器緩存,因?yàn)榇嬖谥鵀g覽器兼容問(wèn)題所以設(shè)置了3個(gè)響應(yīng)頭以覆蓋所有瀏覽器 --><meta http-equiv="Expires" content="0"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Pragma" content="no-cache"> </head> <body><a href="chapter6/ex6_10/validate.jsp">訪問(wèn)validate.jsp頁(yè)面</a> </body> </html> 【2】JSP自定義標(biāo)簽荔枝1)源碼:
<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib prefix="tangrong" uri="/validateTag" %> <tangrong:validate/> 如果您看到了這些內(nèi)容,說(shuō)明本JSP頁(yè)面已經(jīng)正常執(zhí)行完畢! <?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"version="2.0"><tlib-version>1.0</tlib-version><short-name>validateTag</short-name><uri>/validateTag</uri><tag><description>validate tag</description><name>validate</name><tag-class>ex6_8.ValidateTag</tag-class><body-content>empty</body-content></tag> </taglib> package ex6_8;import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport;public class ValidateTag extends TagSupport { // 自定義標(biāo)簽處理器public int doEndTag() throws JspException {HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();String referrer = req.getHeader("referer"); // 訪問(wèn)請(qǐng)求是從哪個(gè)頁(yè)面鏈接過(guò)來(lái)的String sitePart = "http://" + req.getServerName(); // jsp頁(yè)面所在服務(wù)器地址System.out.println("referrer = " + referrer);System.out.println("sitePart = " + sitePart);if (referrer != null && referrer.startsWith(sitePart)) {return EVAL_PAGE;} else {try {pageContext.getOut().write("對(duì)不起,您的訪問(wèn)方式不合法!");} catch (IOException e) {e.printStackTrace();}return SKIP_PAGE;}} } 2)訪問(wèn)效果:
總結(jié)
以上是生活随笔為你收集整理的html模板(base标签,meta标签,禁用浏览器缓存)+JSP自定义标签荔枝的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 世家公子是什么意思 世家公子是指什么
- 下一篇: gradle idea java ssm