起走时间

我的首页
文章
相册
圈子
留言
管理
 
    当前所在页面:首页>>文章>>EasyJWeb vs. Struts
EasyJWeb vs. Struts
    作者:威廉姆 来源:http://bloginside.cn/read.php/141677.htm 发表时间:2007-12-21

 
 

A recent study easyjweb found easyjweb and struts contest, although there has been based on the request of the traditional MVC thinking, but it is do our best java code and separate pages, the result is indeed done this, in the pages easyjweb above you can not find a java code, you will see the following pages html superintendent has become, is not a jsp. In addition, there are unique easyjweb side not only achieved the same as the struts MVC (MVC easyjweb is the core), there is a concrete realization of the following :

1, containers and packaging generic business logic. As one aimed at Java-based Web application development has become a direct, rapid and simple framework EasyJWeb provide a challenging containers, as well as enterprise-class application of some common business logic (such as tabs, query, DAO, etc.) for the abstract and packaging, can provide a set of direct operation, the application of enterprise resource components and API.

2, code generation tools and engines. Relying solely on a flexible, simple MVC core engine can also raise the maximum speed of development, EasyJWeb also provides a flexible, easy-to-use code generator engine and tools, through the use of code generation engine that can be rapidly completed JavaEE Based on the enterprise-class platform for application generation. If the database Tim excision Zha (CRUD) code generation, automatic page template generation, automatic configuration file management.

3, EasyJWeb plug-in system, the various projects, functional expansion and flexibility through plug-in based on the installation of EasyJWeb, provide specific functions. Ajax practical as plug-ins, such as plug-in code generator

    Other I also do not understand the MVC on this Sure! However, I easyjweb and struts are not particularly proficient, I understand their right to talk about my views!
First : Let's look at the configuration file! They have web.xml, the following configuration easyjweb and struts must be some.
Easyjweb the web.xml configuration file

<? Xml version = "1.0" encoding = "UTF-8"? >
<web-app>
<filter>
<filter-name> CharsetFilter </ filter-name>
<filter-class> Com.easyjf.web.CharsetFilter </ filter-class>
<init-param>
<param-name> Encoding </ param-name>
<param-value> Utf-8 </ param-value>
</ Init - param>
<init-param>
<param-name> Ignore </ param-name>
<param-value> True </ param-value>
</ Init - param>
</ Filter>
<filter-mapping>
<filter-name> CharsetFilter </ filter-name>
<servlet-name> Easyjf </ servlet-name>
</ Filter - mapping>
   <servlet>
     <servlet-name> Easyjf </ servlet-name>
     <servlet-class> Com.easyjf.web.ActionServlet </ servlet-class>
   </ Servlet>
   <servlet-mapping>
     <servlet-name> Easyjf </ servlet-name>
     <url-pattern> *. Was </ url-pattern>
   </ Servlet-mapping>
</ Web-app>


Struts of the web.xml configuration :

<? Xml version = "1.0" encoding = "UTF-8"? >
<Web-app xmlns = "http://java.sun.com/xml/ns/j2ee" xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.4 "xsi : schemaLocation =" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
   <servlet>
     <servlet-name> Action </ servlet-name>
     <servlet-class> Org.apache.struts.action.ActionServlet </ servlet-class>
     <init-param>
       <param-name> Config </ param-name>
       <param-value> / WEB-INF/struts-config.xml </ param-value>
     </ Init - param>
     <init-param>
       <param-name> Debug </ param-name>
       <param-value> 3 </ param-value>
     </ Init - param>
     <init-param>
       <param-name> Detail </ param-name>
       <param-value> 3 </ param-value>
     </ Init - param>
     <load-on-startup> 0 </ load-on-startup>
   </ Servlet>
   <servlet-mapping>
     <servlet-name> Action </ servlet-name>
     <url-pattern> *. Do </ url-pattern>
   </ Servlet-mapping>

</ Web-app>

 

Oh, you can see easyjweb and struts through the servlet to handle logical and acceptable http request.
They were handed over to the requests from easyjf - web.xml and struts - config.xml to process the request and control the pages turn. But I say that they are the default configuration file, you can in their web.xml deployment corresponding configuration files.
In the web.xml easyjwb you can add this configuration

  <context-param>
   <param-name> EasyjwebConfigLocation </ param-name>
   <param-value> / WEB-INF/mvc.xml, / WEB-INF/mvc-bbs.xml, / WEB-INF/mvc-ec.xml, / WEB-INF/easyjf-web.xml </ param - value>
  </ Context-param>

The struts I would like Needless to say! Ha ha, or should I say on it! Add on it. Such as :

   <servlet-name> Action </ servlet-name>
     <servlet-class> Org.apache.struts.action.ActionServlet </ servlet-class>
     <init-param>
       <param-name> Config </ param-name>
       <param-value> / WEB-INF/struts-config.xml, / WEB-INF/struts-config-zhangsan.xml, / WEB-INF/struts-config-lisi.xml </ param-value>
     </ Init - param>
If you want to find out more details, see easyjweb Struts configuration file and the note! Google.com on it. Haha. . .


Second : We have to look at their respective easyjf - web.xml and struts - config.xml! Most of them only the simplest Oh!

Easyjf - web.xml configuration of

<? Xml version = "1.0" encoding = "utf-8"? >
<easyjf-web>


<Module path = "/ hello" form = "" scope = "request"
   Action = "com.easyjweb.action.MessageAction" defaultPage = "hehe">
   <Page Name="hehe" url="/message.html" type="template" />

</ Module>
</ Easyjf-web>


Sturts - config.xml configuration of :


<? 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>
   <data-sources />
   <form-beans>
    <form-bean Name="productForm" type="com.cclen.forms.ProductForm"/>
   </ Form-beans>
  <Action path = "/ marketWeb"
      Type = "com.cclen.actions.MarketWebAction"
      Name = "marketWebForm"
      Scope = "request">
      <forward Name="listmarkweb" path="/administrator/proxy/proxy_Add.jsp"> </ forward>
      </ Action>
   </ Action-mappings>
</ Struts - config>


To easyjweb in the configuration file, we need to request hello.ejf com.easyjweb.action.MessageAction treatment.
But there is a module struts more than cattle than what configuration, that is Module also include the Page object, controllers, the interceptors, into the bean.
Here easyjweb can refer to the documents specific understanding. .


Inside struts in the configuration file, we need to request marketWeb.do com.cclen.actions.MarketWebAction treatment.
Oh, the suffix can be arbitrarily changed, the need in web.xml deployment, you try to change it can be understood.

Third : He finally had to Action, and the things we read of view, I know that ah! 10 million on the Internet, I can expect.
1, easyjweb Three of Action were IWebAction AbstractCmdAction AbstractPageCmdAction

  Struts has two types of Acton respectively Action, DispatchAction

They want as a parent, you have to realize their middle way ah!

2, easyjweb IWebAction equivalent to the struts of the Action ah! They were to be achieved through :

IWebAction were to be achieved through :

Public Page execute (WebForms form, Module module) throws Exception;

Struts in Action to be achieved through :

Public ActionForward execute (ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception;

From here, you can see easyjweb the simplicity of his only two parameters, and struts of Action methods have four parameters to test it caused trouble on ah!

3, easyjweb AbstractCmdAction equivalent to the struts of the DispatchAction ah! In a number of Action to provide treatment, for instance :
AbstractCmdAction have such an approach :
Public Page doAdd (WebForms form, Module module) throws Exception;
Public Page doDel (WebForms form, Module module) throws Exception;
Public Page doUpdate (WebForms form, Module module) throws Exception;

In the request to use easyJWebCommand or cmd transmission parameters allowed, as requested, the method name of the form. The rules constitute doXxxx ().
Such as :

Xxx.ejf? EasyJWebCommand = add, it will execute doAdd () methods.
Cmd easyjwebCommand and this is not configurable, asked them not to worry.


Then the struts DispatchAction should be on the method of
Public ActionForward add (ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception;

Public ActionForward del (ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception;

Public ActionForward update (ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception;
In the request to pass struts - config.xml Action of the parameter configuration parameters to transmission,
Such as :
<Action path = "/ marketWeb"
      Type = "com.cclen.actions.MarketWebAction"
      Name = "marketWebForm"
      Parameter = "hahahaha"
      Scope = "request" />
MarketWeb.do? Hahahaha = del, it will execute methods
Public ActionForward del (ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception;

 


However easyjweb AbstractCmdAction of a default method is :
Public Page doInit (WebForms form, Module module)
This way when you are not into specific parameters, to the calling method.
Implementation xxx.ejf used to say, when the implementation of the above


4, the AbstractPageCmdAction easyjweb is very intelligent ah! Struts were really no ah! Easyjweb unique methods.
In AbstractCmdAction, on the basis of EasyJWeb provides another one pair of View with the ability to automatically identify AbstractPageCmdAction. Such applications can "custom configuration instead of" intelligent judgment procedures to be used in the View template, or even less writing signatures can call View template. Such as :
Public void doEdit () ()
This method Although no one source, there was no clear view of the switch or switch. But AbstractPageCmdAction practice principles will automatically choose View edit.html documents as templates.
Niuniu these people ah! Also get so smart out things ah. Admire admire!

 

Fourth : to look at the pair of struts and easyjweb form data access and return! Respectively easyjweb the IWebAction and struts of Action to illustrate the problem!
  One, we must use to achieve IwebAction Method
Public Page execute (WebForms form, Module module) throws Exception;
See! As long as these two parameters, we can solve webForm form data and access to data pages (Back to the data refers to the action which the processed data will be added to the page)
 
The WebForms can be used directly WebForm.get ( "poropertyName") parameters to be text, and binary content for direct use WebForm.getFileElement ( "poropertyName") to handle.
Not normally used form of <form> elements used to define future pages of information form, a WebForms can do that.
WebForms also provides two methods : WebForm.toPo (Object obj) : introduction of an object directly from WebForms copy of the changed value object.

WebForm.toPo (Class clazz) : an imported type, WebForms will initialize this further example of the type of value WebForms copy
Specific methods of this two more usage, please refer to the documents easyjweb : www.easyjf.com

 

Layer and the return data, we must use the new WebForms (). AddResult () data added to the Velocity context. WebForms also provides a simple WebForm.addPo (obj) to handle more than the target attribute value added

We must pay attention to this point ah! WebForms the data to a Velocity context, not only to preserve the use of methods and addPo addResult method Add value, but also to the preservation of Velocity textElement context of the data means that the duplication of data it is not necessary to repeat in Action adding that the application requires special attention.

 

Two, we should use to achieve Action Method
Public ActionForward execute (ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception;
MessageForm messageForm = (MessageForm) form;

You can configure ActionForm to obtain the data, can also request.getParameter (arg0) always data, but here the situation there, but I do not know there's no struts no better solution. For example, binary content, the use of org.apache.struts.upload.FormFile, you must use ActionForm admission to the data.

Returning to the data layer, said on request.setAttribute ( "", object);


Fifth : pages of data output :

1, easyjweb Velocity is used as the engine pages, Velocity grammar simple and easy to learn, and is the favorite artists html pages, where you could not find a java code.
2, struts its own label, or use the sun to support the company JSTL tags, you have to use the pages on the type of target, because you sent to the pages on the object they are not identifiable.
You can jsp pages of the top do not have the code import = ".* rows, java.io .*" This is the java code ah!


Sixth : The pages turn.
1, easyjweb the treatment handed to the Controller Module, is actually a Module contains IWebAction, and the IWebAction, is the call Module resources.
If we return to a page template pages, need only call module.findPage ( "pageName") will be able to access. Because Module configuration gave us the resources :
Such as :
<Module path = "/ hello" form = "" scope = "request"
    Action = "com.easyjweb.action.MessageAction" defaultPage = "hehe">
    <Page Name="hehe" url="/message.html" type="template" />
   </ Module>

It <Page name="hehe" url="/message.html" type="template" /> is to configure the template resources, as long as the com.easyjweb.action.MessageAction through module.findPage ( "hehe") can be called message.html a template. Can also return to direct new Page (,,), such as : return new page ( "9740", "/ user / success.html", "html")


2, in which struts control is handed over to the pages ActionMapping, findForward ActionMapping by calling (), that is ActionMapping.findForward ( "name") shift.

Such as :
  <Action path = "/ product"
             Type = "com.cclen.actions.ProductAction"
             Name = "productForm"
             Parameter = "method"
             >
             <forward Name="listproduct" path="/administrator/product/listproduct.jsp"> </ forward>
            </ Action>
   Com.cclen.actions.ProductAction you need to do to specify which pages ActionMapping.findForward ( "listproduct");


Sixth : I again reiterate the easyjweb struts were not things.

Easyjweb has been able to achieve rapid development, because they give us a better realization of the tools category, powerful supercomputer containers and so on, because I was a beginner, so I proficient in the future will slowly add easyjweb exciting aspects!

 
 

(阅读 )   评论数(:45)
评论】 【收藏】
评论:共45条
oh,my god
评论人: 匿名用户     评论时间: 2007-12-21 10:24:50
hoho~ will ur english has a lot progress... good very good.
评论人: 匿名用户     评论时间: 2007-12-21 17:03:25
To easyjweb in the configuration file, we need to request hello.ejf com.easyjweb.action.MessageAction treatment. -.-!!!
评论人: 匿名用户     评论时间: 2007-12-21 17:04:12
Niuniu these people ah! Also get so smart out things ah. Admire admire! wahahaha~~
评论人: 匿名用户     评论时间: 2007-12-21 17:29:09
another question ,who's the author?
评论人: 匿名用户     评论时间: 2007-12-21 17:31:22
评论人: ...     评论时间: 2008-02-05 05:42:50
评论人: ...     评论时间: 2008-02-24 17:57:12
评论人: ...     评论时间: 2008-02-25 03:02:06
评论人: ...     评论时间: 2008-02-25 12:00:08
评论人: ...     评论时间: 2008-02-25 20:17:15
评论人: ...     评论时间: 2008-02-26 04:06:03
评论人: ...     评论时间: 2008-02-26 11:47:03
评论人: ...     评论时间: 2008-02-26 19:12:48
评论人: ...     评论时间: 2008-02-27 02:12:50
评论人: ...     评论时间: 2008-02-27 09:15:28
评论人: ...     评论时间: 2008-02-27 16:18:10
Quella http://www.galcios.cn/nudismo poco [URL=http://www.galcios.cn/siti-donne] siti non donne [/URL] loro http://www.galcios.cn/concessionario ex.
评论人: ...     评论时间: 2008-02-28 05:29:47
评论人: ...     评论时间: 2008-03-04 12:01:24
评论人: ...     评论时间: 2008-03-05 02:43:02
评论人: ...     评论时间: 2008-03-05 17:40:33
评论人: ...     评论时间: 2008-03-05 17:41:47
评论人: ...     评论时间: 2008-03-06 09:12:58
评论人: ...     评论时间: 2008-03-06 09:17:36
评论人: ...     评论时间: 2008-03-07 00:13:34
评论人: ...     评论时间: 2008-03-07 00:13:46
评论人: ...     评论时间: 2008-03-07 10:50:07
评论人: ...     评论时间: 2008-03-07 20:00:52
评论人: ...     评论时间: 2008-03-08 05:02:17
评论人: ...     评论时间: 2008-03-08 05:04:26
评论人: ...     评论时间: 2008-03-08 13:36:48
评论人: ...     评论时间: 2008-03-08 13:45:14
jdvdljvf http://txkdnvll.com dstzjhmf rjkdbfkn  [URL=http://sxyriydq.com]bnpfwykx[/URL]  <a href="http://evzlrqlh.com">loucqldn</a>
评论人: qmqnajbe     评论时间: 2008-04-20 18:59:51
rjtpooty http://cgmefevn.com qewrkbzg fzipvkni  [URL=http://brntpakg.com]krheddux[/URL]  <a href="http://zqfshcpr.com">lditkmec</a>
评论人: svmvgcii     评论时间: 2008-04-20 19:09:16
[URL=http://mqutdfwe.com]unccklmb[/URL]  <a href="http://hpjertoq.com">nzgpmmhv</a>  lyqkairb http://urnrykot.com hdlrxeqe sfkdrlgb
评论人: rttdavcu     评论时间: 2008-04-20 19:12:29
[URL=http://hzvladuv.com]udpszltf[/URL]  <a href="http://epaxyvlh.com">nvgmfhwr</a>  sqnkygja http://utdxodrj.com ntymiiju ufcvgsib
评论人: coiujtsj     评论时间: 2008-04-20 19:14:57
dbhakmxe http://pdgjpvdx.com bgqpnppu xypxcfdu  [URL=http://innqtliu.com]vomipxlv[/URL]  <a href="http://qftlmoos.com">shhqrpvj</a>
评论人: jylpnycr     评论时间: 2008-04-20 19:29:31
osvneswb http://zlnfhkem.com dnxtdgbo orzldrbn  <a href="http://dgvjxipg.com">lyenravk</a>  [URL=http://llabobse.com]kmfxfyeq[/URL]
评论人: ojdgzeul     评论时间: 2008-04-20 19:35:21
<a href="http://nwugzhme.com">qnkvhkac</a>  [URL=http://ojjmnrqz.com]filgszvy[/URL]  smqbtyxv http://pjocxdpp.com vlzrpkuv fubrvglq
评论人: gspfldll     评论时间: 2008-04-21 09:49:49
erhdvmlp http://tuoowvih.com kgwvpuhz eaklthpi  <a href="http://ihjselxy.com">ynvhhzag</a>  [URL=http://dbnzpsdi.com]itrqiptu[/URL]
评论人: zfxkejla     评论时间: 2008-04-21 09:57:13
评论人: ghDfXzUBvJv     评论时间: 2013-01-04 05:03:38
评论人: TXCVsufEGlWXLVK     评论时间: 2013-01-04 15:08:24
评论人: mRQoOdpGJNWY     评论时间: 2013-01-06 20:39:15
评论人: JyYpKZBWqoXXfcEYX     评论时间: 2013-01-07 04:52:43
评论人: BrettfrinI     评论时间: 2017-05-30 16:04:36
wh0cd343469 <a href=http://buyavana.us.org/>order avana online</a> <a href=http://losartanhydrochlorothiazide.us.com/>hydrochlorothiazide online</a>
评论人: BrettfrinI     评论时间: 2017-07-18 09:58:19

发表评论:
发表人:
评论: 
验证码:
请输入前面图中的四位验证码,字母不区分大小写
  
 
关于我们 | 诚聘英才 | 联系我们 | 广告业务 | 网站地图 | 法律声明

EasyJF开源团队版权所有  建议使用1024*768分辨率