欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Sprout - annotation powered simplicity for Struts

Sprout

Annotation-PoweredSimplicity for Struts

2/19/06: Sprout 0.9.1 released.

Overview

Sprout aims to significantly simplify development with Struts byreducing the amount of configuration required through the use ofannotations.

Basics

Sprout requires JDK 1.5 and Struts 1.2.6 or later. Without those, you‘re out of luck.

Sprout is an extension of a StrutsMappingDispatchAction, which allows for multiple actions tobe defined within the same Action class. In this case, thename of the method is mapped to the URL (after converting method names;methodName is exposed as /method_name.do). Paths aredetermined based on the package name of the action. For example,net.mojodna.sprout.action.HomeAction corresponds to /,while net.mojodna.sprout.action.example.ExampleActioncorresponds to /example/.

Sprout also uses a custom RequestProcessorSproutRequestProcessor, which extends Spring‘sDelegatingRequestProcessor. This means that you can specifydependencies within your actions using setter-injection.

Sprout is also completely backward-compatible with legacyStruts applications.. It was built for use in a legacy Strutsapplication; many of the older Actions are untouched — newdevelopment is done using Sprout (I often find myself removingaction-mappings while adding new functionality).

Annotations

All annotations are optional.

@FormName

Allows the developer to override the name of the form-bean (definedin struts-config.xml) used for this method. This is equivalentto setting the name attribute within an actionmapping.

Defaults to ${action-name}Form; e.g. forAdminAction the default ActionForm name would beAdminActionForm.

@Forward

Specifies additional forwards. Multiple forwards may be specified byproviding arrays as arguments to name, path, andredirect. redirect defaults to false.

A default redirect is provided; the key isSprout.FWD_SUCCESS and the path is the converted path +.jsp. E.g., AdminAction.methodName() corresponds tomethod_name.jsp.

e.g. @Forward(name="failure", path="/failure.jsp"redirect="true")

@Input

This annotation is required if this action is validating the outputfrom a different action. In that case, the argument to @Inputshould be the path to the JSP containing the form whose input is beingvalidated.

e.g @Input("login.jsp") if this is not login()and the action that initiated this request islogin().

@Scope

Specifies the scope attribute for the generated actionmapping. This exists primarily for completeness; it is likely that youmay never use this annotation.

As with struts-config.xml, the default isrequest.

@Validate

Specifies the validate attribute for the generated actionmapping. Set this to true if you desire the output of thisaction to be validated. For this to have any effect, you must havespecified rules in validator-rules.xml.

Sprout does not contain anything to ease the actual validationprocess at this time.

Example

src/java/net/mojodna/sprout/action/example/ExampleAction.java:

// URL should be /example/*package net.mojodna.sprout.action.example;
// ...
public class ExampleAction extends Sprout {// overrides Sprout.index()public ActionForward index( ... ) {// do something
// redirect to index.jspreturn mapping.findForward( FWD_SUCCESS );}}

_src/java/applicationContext.xml:

...<bean name="ExampleAction"class="net.mojodna.sprout.action.example.ExampleAction" singleton="true"/>...

src/web/WEB-INF/struts-config.xml:

...<form-bean name="ExampleActionForm"type="org.apache.struts.validator.DynaValidatorForm"><form-property name="..." type="..." />...</form-bean>
<!-- No action-mappings!!! --><action-mappings />
<!-- Define an alternate RequestProcessor --><controllerprocessorClass="net.mojodna.sprout.SproutRequestProcessor" />
<!-- Sprout plug-in --><plug-in className="net.mojodna.sprout.SproutAutoLoaderPlugIn" />...

Shorthand

Index Actions

Sprout contains an index() method to speed up the process ofgetting something working. To use this, subclass Sprout (no methodsnecessary), register the action-bean in applicationContext.xmland create a corresponding index.jsp. When you need to addlogic to the action, override index() in your Sprout sub-classand add it there.

DynaActionForms

Helper methods have been added to ease development usingDynaActionForms.

String key = "foo";String value = "bar";// returns a Stringf( key ) == ((DynaActionForm) form).getString( key );
// returns an ObjectF( key ) == ((DynaActionForm) form).get( key );
// sets a values( key, value ) == ((DynaActionForm) form).set( key, value );

ActionMessage handling

Sprout contains adaptations to the traditional way Struts handlesActionMessages. getMessages() andgetErrors() have been modified to store and retrievemessages from the session rather than the request. This means thatmessages and errors will be displayed (and subsequently cleared) on thenext invocation of <html:messages /> or a variant(such as <ui:notifications />), regardless of whethereither of the get methods have been called or if the invocationoccurs during a separate request.

Sample message / error handling code (within an Action):

ActionMessages msgs = getMessages( request );ActionMessages errors = getErrors( request );
// Add a messagemsgs.add( ... );
// Add an errorerrors.add( ... );
// Save messages and errorssaveMessages( request, msgs );saveErrors( request, errors );

<ui:notifications />(src/web/WEB-INF/tags/ui/notifications.tag) is an alternativetag file that can be modified for your use. The primary differencebetween <html:messages /> is that it will displayboth messages and errors (and will discriminate between them, allowingyou to style them differently depending on your application‘sneeds).

Servlets and Taglibs

Spring‘s Struts integration lacks the ability to autowire servletsand taglibs. Sprout contains classes (Sproutlet andSproutTag) that can be subclassed to provide auto-wiringcapability. They will be wired during their initialization process.

These support classes only support the byNameauto-wiring mechanism.

Q + A

  • Q: Why the Spring dependencies?
  • A: I‘m already using Spring. There‘s a good chance that you are as well. Removing the dependency makes reflection upon the registered actions (or finding them in the first place) significantly more difficult.
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
struts2最簡(jiǎn)單的配置(不信你來(lái)看看)
運用Jakarta Struts的七大實(shí)戰心法
關(guān)于struts2中namespace和s:form action和form action 路徑問(wèn)題
Struts Hibernate簡(jiǎn)化J2EE的文件操作
java學(xué)習路線(xiàn)圖
Struts2利用convention
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久