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,如需转载请自行联系原作者


相关文章
|
安全 Java API
Struts2
访问web资源 1》使用servlet API解耦的方式,获取的方法较少   1.使用ActionContext,一个一个获取,效率不高   2.实现XxxAware接口(ApplicationAware,SessionAware.....)推荐,
44 0
|
设计模式 开发框架 安全
Struts,你为何死不悔改!
上篇文章《诡异的字符串问题。。。》的问题已经解决了,我一直相信「团队力量的重要性」,虽然我不能保证加入群的每一个人都是乐于分享的同学,但我始终群里的各位同学总会慢慢被我们这种乐于分享的群氛围所影响。就以上篇文章为例,群里的 Univechige 同学专门给 IntelliJ IDEA 官方发邮件寻求原因,这便是一个好的开端,我相信有各位同学的共同维护,后面群氛围会越来越好。下面给出 IDEA 官方的答复,见下图。
177 0
Struts,你为何死不悔改!
|
Web App开发 Java Apache
struts
运行流程 客户端浏览器通过HTTP请求,访问控制器,然后控制器读取配置文件,然后执行服务器端跳转,执行相应的业务逻辑,然后,在调用模型层,取得的结果展示给jsp页面,最后返回给客户端浏览器 组成部分 struts 视图 标签库 控制器 action 模型层 ActionFrom JavaBean struts maven 安装官网 : https://struts.
1012 0
|
Web App开发 XML Java
JakartaEE Struts2使用
1. Struts2下载 解压后的目录结构如下: 图1.png 从一个高水平角度看,Struts2 是一个MVC拉动的(或MVC2)框架,Struts2 的模型-视图-控制器模式是通过以下五个核心部分进行实现的: 操作(Actions...
1029 0
|
Java 数据库连接
[Struts]HibernatePlugIn for Struts(转贴)
这个Plugin的作用是在Struts应用程序启动时进行hibernate的初始化操作,原文HibernatePlugIn for Struts,步骤很简单: 1、在struts-config.xml里增加: <plug-in className="org.
1169 0
|
SQL JavaScript 前端开发
|
Java 数据安全/隐私保护 开发者
|
Web App开发 JavaScript Java