开发者

Understanding the struts2 configuration file

The below piece of code was written in struts-config file.but i am not able to understand it.

   <action path="/showWelcome"
            type="com.code.base.presentation.struts.actions.StrutsIoCAction"
            name="LoanDetailPageLoadForm"
            parameter="GET_WELCOME_PAGE"
            input="welcomePage"
            validate="false"
            scope="request">
        <set-property property="requestDTOKeyName" value="ItemDataRequest" />
        <set-property property="responseDTOKeyName" value="ItemDataResponse" />
        <set-property property="exceptionDTOKeyName" value="ProfileSekerException" />

        <set-property property="businessServiceId" value="ItemsDataMgm开发者_如何学GotService" />

        <forward name="success" path="welcomePage" />
        <forward name="failure" path="sysError" />
    </action>

My question is

  1. what is the usage of path attribute?
  2. what is the usage of parameter attribute?
  3. what is the usage of input attribute?
  4. what is the usage of <set-Property>?

Help me guys on this.

Note: as per my understanding there should be "showWelcome.jsp" page in the application but it is not there.(then what is use of that?)


  1. It specifies where the action is mounted. For example, this action would respond on http://yourservice.dom/showWelcome.
  2. Parameter is the string you get by calling ActionMapping.getParameter(). Any string you want to pass to your action.
  3. Input is a path where the user would be redirected if he fills the form incorrectly. As there's validate=false, I'd say that would never happen.
  4. Obviously, it sets a property on com.code.base.presentation.struts.actions.StrutsIoCAction. I think it calls setter, i.e. it would call setRequestDTOKeyName(), setResponseDTOKeyName() etc.

But if you're going to use struts for a considerable time, QA won't get you far, read some docs on struts' config file.


Following on from @Alamar's response...

There is no showWelcome.jsp. "/showWelcome" is the URL, but that does not correspond to the name of any actual filename on the server. If this action's configuration contained a line like this:

<forward name="success" path="showWelcome.jsp" />

Then it would mean that if the action class (StrutsIoCAction) returns success, a file called showWelcome.jsp would be executed. However, as you can see, the actual configuration is a forward to "welcomePage", which is probably not a file but instead the name of another action (also defined in struts-config).

Note: "forward" just means that execution is passed to this other action, it does not mean that the user is redirected to another URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜