项目采用的支撑框架Struts2.09,Spring2 Hibernate3.2.在项目开发过程中.采用Struts2.09开发中采用model-driven的方式来获取对象产生了一些奇怪的问题.第一个问题:
我在action中如果只配置:
<interceptor-ref name="model-driven"/>
例如在我的UserAction就获取不到User对象.user.jsp页面我是按照model-driven的写法如:
user.userName user.userPasswd用的也是strtus2的标签.在Action中同样写了对应的
private User user = new User();
private User getUser(){...}
private void setUser(User user){...}
奇怪的是获取不了页面传来的user对象属性,如果用getParemeter("user.userName")是可以获得值的.
但是在Action中再增加其它的拦截器如:
<interceptor-ref name="validationWorkflowStack" />
或者干脆增加:
<interceptor-ref name="defaultStack"/>
这样Action中的User对象就能顺利获取页面传来的属性值了.
<package name="userManger" extends="struts-default">
<action name="albumAction" class="com.xx.struts.action.UserAction">
<result name="success" type="dispatcher">
<param name="location">/userinfo.jsp</param>
</result>
<interceptor-ref name="model-driven"/>
<interceptor-ref name="validationWorkflowStack" />
</action>
</package>
但是这样又出现一个奇怪的问题.就是我的Action中的代码会多执行一次.例如
我的Action中默认的execute()方法中有一段:
user.setCreateTime(new Date())
user.setUserStatus(Constans.IS_LEGALITY);
.....
UserManager.save(user);
这段在execute()方法中的代码会在第一次保存完之后又返回重新执行一次.
这个时候程序当然就会报异常了,有些需要从页面上获得的属性在数据库中是必填的就会报值不能空的异常了.但是事实上是通过Debug可以发现程序的execute的方法重复执行了一次.且控制台也打印出两条insert语句了.刚开始我还以为是hibernate invert配置问题.后来通过debug排除这种问题.不知道这种原因有谁有较深入的了解.或者也同样出现个,请指教一下,谢谢
分享到:
- 2007-09-10 14:14
- 浏览 11873
- 评论(19)
- 论坛回复 / 浏览 (19 / 16612)
- 查看更多
相关推荐
Model-Driven Architecture
Model-driven engineering technologies offer a promising approach to address the inability of third-generation languages to alleviate the complexity of platforms and express domain concepts effectively...
Graph Transformations and Model-Driven Engineering -- Essays Dedicated to Manfred Nagl on the Occasion of his 65th Birthday Lecture Notes in Computer Science 5765
Model-driven applications: Using model-driven mechanism to bridge the gap between business and IT. In Díaz, V. et al. eds, Advances and Application in Model-Driven Software Engineering, ch. 3, pp. ...
MDA Distilled is an accessible ... You will also learn how to define a model-driven process for a project involving multiple platforms, implement that process, and then test the resulting system.
Patterns: Model-Driven Development Using IBM Rational Software Architect First Edition (December 2005) This edition applies to Version 6.0.0.1 of Rational Software Architect (product number 5724-I70).
MDA 模型驱动开发 UML
Executable UML: A Foundation for Model-Driven Architecture,这本书虽然是02年出的,但是是MDA中很重要的研究方向,我们讨论组主要翻译了第一、二和章。
With the arrival of the big data era, data requirements are gradually no longer an obstacle (at least for many areas), but the determination of network topology is still a bottleneck....
Model-Driven Mechanism in Information Systems and Enterprise Engineering 暨大2007讲座中部分内容的英文版
Principles of Model-Driven Architecture - 2004
Model-Driven Development with Executable UML
英文原版,模型驱动软件建模领域经典书, 作者:Marco Brambilla Politecnico di Milano Jordi Cabot École des Mines de Nantes ManuelWimmer Vienna University of Technology
The Model-Driven Semantic Web-SSI-EW-2005-08-16
such as components, model-driven architectures (MDA), and product lines. These technologies drastically alter the software development process, which is characterized by a high degree of innovation ...
NULL 博文链接:https://zw7534313.iteye.com/blog/429869
The aim of this book is to give an overview of the state of the art in model-driven software development. Achievements are considered from a conceptual point of view in the first part, while the ...
With Sculpture you can model your application components, and then transform this model to deployable components with your favorite technology. Sculpture comes with a host of ready-made Molds (The ...
第二部分视频 博文链接:https://dlivan.iteye.com/blog/56826
MODEL-DRIVEN DEVELOPMENT OF GRAPHICAL TOOLS