您的位置:首页 > 编程语言 > Java开发

Something about struts1.2-using

2009-10-03 12:59 351 查看
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.

If you want to show all info in ActionMessages object, so you should use " message='true'" item.
If you want to show some property info of ActionMessages object, use like this "message="true" property="info""
If you want to show all info in ActionErrors object, you may should use none of the "message" & "property".
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息