正文

HTML标记库 - HTML基本元素标签2007-03-13 10:22:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/hurongliang/23905.html

分享到:

html:html server <html:html lang=”true”> client <html lang="zh-CN">   html:base server: <html:base /> <%=request.getServerName()%> client: <base href="http://localhost/123/taglib/html/test1.jsp"> localhost   html:link html:link page使用相对与此应用程序的路径,而不是相对于服务器的相对路径,且与是否使用html:base无关 添加参数有三种方法 1.  直接添加 2.  使用paramId和paramName属性,如果是使用Bean则需同时使用paramName和paramProperty指定参数。 3.  定义一个Map,将此Map赋值给name属性作为变量参数 html:rewrite 用法和html:link一样,只是他直接跳转,而html:link给你一个链接,点击链接后才跳转 html:img 如果使用page属性指定图片位置,则此位置是相对于应用程序的位置,如果使用src则是相对于服务器的位置。 height和width属性可以对图片进行缩放。 可以传参,方法跟html:link相同。 使用示例 test1.jsp: <%@ page language="java" pageEncoding="UTF-8"%>   <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html:html lang="true">   <head>     <html:base />     <title>test1.jsp</title>       <meta http-equiv="pragma" content="no-cache">     <meta http-equiv="cache-control" content="no-cache">     <meta http-equiv="expires" content="0">        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">     <meta http-equiv="description" content="This is my page">     <!--     <link rel="stylesheet" type="text/css" href="styles.css">     -->     </head>     <body>   <h1>html:img:</h1>   <html:img page="/image/image1.jpg" height="400"/>   <hr>   <%=request.getServerName() %>     This a struts page. <br>     <html:link forward="linktopage">to test2.jsp by forward</html:link><br/>     <html:link href="http://www.google.com">to google</html:link><br/>     <html:link page="/taglib/html/test2.jsp">to test2.jsp by page</html:link><br/>     含参数1<br/>     <html:link href="http://www.google.com?school=cancit&amp;xi=5">to google</html:link><br/>      含参数2<br/>     <%      String zhuanye = "计算机科学与技术";     pageContext.setAttribute("zhuanye",zhuanye);      %>     <html:link page="/taglib/html/test2.jsp" paramId="zhuanye" paramName="zhuanye">to test2.jsp</html:link><br/>      含参数3<br/>     <%     java.util.HashMap info = new java.util.HashMap();     info.put("school","cancit");     info.put("xi","5");     info.put("zhuanye","计算机科学与技术");     pageContext.setAttribute("info",info);      %>      <html:link forward="linktopage" name="info">to test2.jsp</html:link><br/>   </body> </html:html>   test2.jsp</html:link><br/>   </body> </html:html> test2.jsp: <%@ page language="java" pageEncoding="UTF-8"%>   <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html:html lang="true">   <head>     <html:base />         <title>test2.jsp</title>       <meta http-equiv="pragma" content="no-cache">     <meta http-equiv="cache-control" content="no-cache">     <meta http-equiv="expires" content="0">        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">     <meta http-equiv="description" content="This is my page">     <!--     <link rel="stylesheet" type="text/css" href="styles.css">     -->     </head>     <body>   <hr/>   request params:<br/>   <%   java.util.Enumeration e = request.getParameterNames();   pageContext.setAttribute("e",e);    %>    <c:forEach items="${e}" var="names">    <c:out value="${names}" />: <%=request.getParameter(pageContext.getAttribute("names").toString()) %><br/>    </c:forEach><br/>    This a struts page. <br/>   </body> </html:html> struts-config.xml:   <global-forwards >     <forward name="linktopage" path="/taglib/html/test2.jsp" />   </global-forwards>

阅读(2677) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册