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>
<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.
本文转自danni505 51CTO博客,原文链接:http://blog.51cto.com/danni505/209427,如需转载请自行联系原作者