当前位置: 代码迷 >> Java Web开发 >> 100 求struts-config.xml文件,和action +actionform + dao的一个类解决思路
  详细解决方案

100 求struts-config.xml文件,和action +actionform + dao的一个类解决思路

热度:703   发布时间:2016-04-17 13:15:24.0
100 求struts-config.xml文件,和action +actionform + dao的一个类
大虾们
本人写struts   没什么经验
而且都是自学的
感觉我做的东西   管理和规划不是很好
问题如下:
1、class的设计不规范,导致dao中文件过多,文件内部的不效、重复代码过多
2、action层中文件过多
(struts_config.xml我喜欢用动态的actionform)
不知大虾们可否帖一些代码让小弟学习学习

struts如何管理
类如何设计

先谢了哈
在下邮箱:longhailing20@163.com


------解决方案--------------------
正常的就应该是:
jsp-> action-> biz-> dao
-------------------->
form

每一个模块按照规范的编码,就应该有这么一套程序.
如果真要提炼通用的代码,那就需要根据具体的业务需求而定啦
------解决方案--------------------
正常的就应该是:
jsp-> action-> biz-> dao
-------------------->
form

每一个模块按照规范的编码,就应该有这么一套程序.
如果真要提炼通用的代码,那就需要根据具体的业务需求而定啦
---------------------------------------------
我的习惯是from不和底层打交道,我都会用一个dateentity传入后台!
------解决方案--------------------
李兴华讲的DAO设计模式,和STRUTS入门比较不 错.可以看一下.
------解决方案--------------------
struts-config.xml

<?xml version= "1.0 " encoding= "UTF-8 "?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN " "http://struts.apache.org/dtds/struts-config_1_2.dtd ">

<struts-config>
<form-beans>
<form-bean name= "userActionForm " type= "com.jxtelexc.dinner.form.UserActionForm " />
<form-bean name= "voteActionForm " type= "com.jxtelexc.dinner.form.VoteActionForm " />
<form-bean name= "departActionForm " type= "com.jxtelexc.dinner.form.DepartActionForm " />
<form-bean name= "messageActionForm " type= "com.jxtelexc.dinner.form.MessageActionForm " />
<form-bean name= "eateryActionForm " type= "com.jxtelexc.dinner.form.EateryActionForm " />
<form-bean name= "orderActionForm " type= "com.jxtelexc.dinner.form.OrderActionForm " />
</form-beans>
<action-mappings>
<action name= "userActionForm " path= "/userAction " scope= "request " type= "com.jxtelexc.dinner.action.UserAction " validate= "true ">
<forward name= "loginok " path= "/main.jsp " />
<forward name= "error " path= "error.jsp " />
<forward name= "loginfail " path= "/index.jsp " />
</action>
<action name= "departActionForm " path= "/departAction " scope= "request " type= "com.jxtelexc.dinner.action.DepartAction " validate= "true " />
<action name= "eateryActionForm " path= "/eateryAction " scope= "request " type= "com.jxtelexc.dinner.action.EateryAction " validate= "true " />
<action name= "messageActionForm " path= "/messageAction " scope= "request " type= "com.jxtelexc.dinner.action.MessageAction " validate= "true ">
<forward name= "error " path= "/error.jsp " />
<forward name= "ShowAll " path= "/showAllMessage.jsp " />
<forward name= "Del " path= "/showAllMessage.jsp " />
<forward name= "DelAll " path= "/showAllMessage.jsp " />
<forward name= "Add " path= "/showAllMessage.jsp " />
  相关解决方案