Struts1.2.4学习心得!(-)

第一次学习:

1.直接转发配置,在struts-config.xml 可以直接将请求转到指定位置:
如:<action path="/welcome" forward="/index.html" />
当在网页上打开 welcome.do时,自动跳到index.html

2.cookie的使用:
在JSP网页头部增加一句:<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
用下面的代码新建cookie.
< bean : cookie id="sess" name="JSESSIONID" value="JSESSIONID-IS-UNDEFINED" / >
取cookie的值:
(1)< jsp:getProperty name="sess" property="comment" />
这种取法,当comment为空时,显示null
(2)< bean:write name="sess" property="comment" />
这种取法,当comment为空时,什么也不显示

3.int,float,string等数据类型在网页上的显示:

设有一个TestBean的BEAN的函数返回多种数据类型. 用下面语句取 bean对象.
<jsp:useBean id="test1" scope="page" class="org.apache.struts.webapp.exercise.TestBean" />
用下面语句定义返回的各种数据类型的值:
java代码: 

  1 
  2 < bean:define id="test1_boolean" name="test1" property="booleanProperty" />
  3  < bean:define id="test1_double" name="test1" property="doubleProperty" />
  4  < bean:define id="test1_float" name="test1" property="floatProperty" />
  5 < bean:define id="test1_int" name="test1" property="intProperty" />
  6  < bean:define id="test1_long" name="test1" property="longProperty" />
  7  < bean:define id="test1_short" name="test1" property="shortProperty" />
  8 < bean:define id="test1_string" name="test1" property="stringProperty" />
  9 


用下面的方法显示值:
java代码: 

  1 
  2 <%= test1_boolean %>
  3 <%= test1_double %>
  4  <%= test1_string %>
  5 ................
  6 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值