html:link 各个属性解释及用法
<html:link> 标签用于生成HTML <a> 元素。<html:link> 在创建超链接时,有两个优点:
(1) 允许在URL 中以多种方式包含请求参数。
(2) 当用户浏览器关闭Cookie 时,会自动重写URL,把SessionID 作为请求参数包含在URL 中,用于跟踪用户的Session 状态。
<html:link> 标签有以下重要属性:
(1) forward:指定全局转发链接。
(2) href:指定完整的URL 键接。
(3) page:指定相对于当前网页的URL。
<html:rewrite> 用于输出超链接中的URI部分,但它并不生成HTML <a> 元素。URI指的是URL 中协议、主机和端口以后的内容。URI 用于指定具体的请求资源。例如,对于URL:HTTP://localhost:8080/HtmlBasic.do,它的URI为 /HtmlBasic.do
示例:
1、创建全局转发链接
首先,在Struts-config.xml 中<global-forwards> 元素中定义一个<forward> 元素:
<global-forwards>
<forward name = "index" path="/index.jsp"/>
</global-forwards>
接着,在JSP 文件中创建<html:link> 标签:
<html:link forward="index">
Link to Global ActionForward
</html:link>
<html:link> 标签的forward 属性和<global-forwards> 元素中的<forward> 子元素匹配。以上代码生成如下HTML 内容:
<a href="/index.jsp" mce_href="index.jsp">Link to Global ActionFoward</a>
值得注意的是,<html:link> 的forward 属性只引用Struts-config.xml 配置文件中<global-forwards>内的<forward> 子元素,如果引用<action> 内的<forward> 子元素,在运行时将会抛出异常:
Cannot c
相关文档:
例如从1.html跳转到2.html:
在1.html中:
<form name="loginForm" action="2.htm?pageid=1&str='s'" method="post">
当页面提交跳转到2.html中:
<script type="text/javascript">
<!--
var str = location.search;
//-->
&l ......
StringBuilder sb = new StringBuilder();
Server.Execute("~/Default2.aspx", new StringWriter(sb));
File.WriteAllText(Server.MapPath("index.htm"), sb.ToString()); ......
//截取部分内容方法
public static string strvalue(string value, int length)
{
string strValue = NoHTML(value);// 去除HTML标记
&nb ......
在WEB应用中,如果使用jsp作为view层的显示模板,都会被空格/空换行问题所困扰.
这个问题当年也困扰了我比较长的时间.因为在jsp内使用的EL标签和其他标签时,会产生大量的空格和换行符.例如:
------- start ----------
<c:choose>
<c:when test="${fn:length(mainPageList)>1&}&q ......