爱在深秋

 

Struts中html-link标签

<html:link>s标签
                       转自:http://www.lupaworld.com/42237/viewspace_17781.html

1.1. 页面跳转

  可以使用href、page、action三个属性实现struts视图层组件的跳转,三个属性的作用及区别为:① href使用该域名下的相对路径,路径前不需要加“/”,或链接至以http开头其它域名,href="index.jsp"、href="http: //www.baidu.com";② page使用该域名下的绝对路径,路径前需要加“/”;③ action使用该域名下的绝对路径,路径前需要加“/”,与page的区别是可以省略.do;为了生成“http://localhost: 8080/941ok/chat/questFriendIndex.do”这样的链接,分别使用href、page、action的实现如下:
  href="questFriendIndex.do";
  page="/chat/questFriendIndex.do";
  action="/chat/questFriendIndex"、action="/chat/questFriendIndex.do";

1.2. 参数传递
  ① 传递静态参数,直接写在URL里,例如:href="questFriendIndex.do?username=1&password=1";
  ② 传递单个动态参数,通过paramId,paramName和paramProperty属性传递Bean里的单个值。paramId属性告诉jsp编译引擎要传送的参数名称是什么,“?”号后面,“=”号前面的内容;paramName属性和paramProperty属性告诉编译引擎使用哪个Bean 的哪个属性值,构造“=”后面的内容。如果beanName的property beanProperty的值为beanPropertyValue,那么<html:link page="chat/questFriendIndex.do"  paramId="param_name" paramName="beanName" paramProperty="beanProperty">对应的url是http://localhost: 8080/941ok/chat/questFriendIndex.do?param_name=beanPropertyValue;
  ③ 传递多个动态参数,通过name属性传递在request对象里设置的Map类型的对象里的多个参数;假设如果你定义下面的一个map:
Map mapName=new HashMap();
mapName.put("paramValue1","value1");
mapName.put("paramValue2","value2");
request.setAttribute("mapName",mapName);
在jsp页面有下面的一个链接:
<html:link action="/chat/questFriendIndex" name="mapName">
对以的链接是:
http://localhost:8080/941ok/chat/questFriendIndex.do?paramValue1=value1&paramValue2=value2

1.3. 示例应用结构
{$tomcat_home\webapps}
|__941ok
  |__WEB-INF
  |__chat
    |__index.jsp
    |__questFriendIndex.do

posted on 2008-10-15 09:29 爱在深秋 阅读(183) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(1)

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜