Something about struts1.2-using

Topic 1:About Mapping
 
Q:What's difference between this two code?
mapping.findForward(mapping.getInput());
AND
mapping.getInputForward();
 
Re:
Mapping.getInput() which type is String, and as we know, mapping.findForward(), which will find the forword String from Struts Content setted in cfg xml file, so if use it we must set "<forward ... />" if not will can't find the item page and in console will out an "Unable to find '/messageinfo.jsp' forward. " log, and page will forword an null page.
 
while mapping.getInputForward(), which type is a ActionForward, and getInputFroward() which get the Input page setted in cfg.xml, so when use it you should set "input" page in "<action input="somePage.jsp" .../> ", if not, it will throw an exception, and you cann't get any correct page!
 
 
Topic 2:About Action's Messages
Q:What's difference of those code? Can you guess the results?
---------------------------------------<br> 
<html:messages id= "message"
    <bean:write name= "message"/> 
    <br/> 
</html:messages> 
--------------------------------------<br> 
<html:messages id= "message" property= "info"
    <bean:write name= "message"/> 
    <br />    
</html:messages> 
-------------------------------------<br> 
<html:messages id= "message" message= "true"
    <bean:write name= "message"/>    
    <br />    
</html:messages> 
-------------------------------------<br> 
<html:messages id= "message" message= "true" property= "info"
    <bean:write name= "message"/> 
    <br /> 
</html:messages>
 
Re:
As you see, the main difference is some use "message", and some use "property" attribute, so that's the key.
  1. If you want to show all info in ActionMessages object, so you should use " message='true'" item.
  2. If you want to show some property info of ActionMessages object, use like this "message="true" property="info""
  3. If you want to show all info in ActionErrors object, you may should use none of the "message" & "property".
  4. If you want to show some property info of ActionErrors object,  you may need to use as "property="info""
And have a try in you eclipse, it's may be have a littlr funning.
Note:
Here the messages object should construct as like this:
msgs.add( "okinfo"new ActionMessage( "send ok!", false));
 
Topic 3:Ibatis CharSet
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/taxims?useUnicode=true&characterEncoding=UTF-8"/>
If the whole app use UTF-8, include mysql also use default charset utf-8, and ibatis have been used, you should set this code to set the JDBC's charset is utf-8, then you can insert utf-8 char into db.




    本文转自danni505 51CTO博客,原文链接:http://blog.51cto.com/danni505/209427,如需转载请自行联系原作者


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值