English 中文(简体)
如何准备截击器在2号柱子上工作?
原标题:How prepare interceptor works in struts2?

Please tell me how the prepare intercetor works I am using it now & found strage behaviour

prepare()
validate()
execute()

这些都是方法

所以当我按下请求时 它调用3次

prepare()
validate()
execute()
prepare()
validate()
execute()
prepare()
validate()
execute()

I dont know whats the problem with it According to my understanding it should only run prepare method & show prepopulated data form & when user clicks on submit then it should submit the data.

请解释解释

<action name="updatebusinessinfo" class="com.controller.UpdateBusinessDetails">

            <interceptor-ref name="params"/>
            <!--
            <interceptor-ref name="prepare"/> 

            <interceptor-ref name="basicStack"/>
            -->

            <interceptor-ref name="fileUpload">
                    <param name="maximumSize">2097152</param>
                    <param name="allowedTypes">image/png,image/gif,image/jpeg,image/pjpeg</param>
            </interceptor-ref>
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <result name="success">businessinfo.jsp</result>
            <result name="input">businessinfo.jsp</result>
            <result name="error">businessinfo.jsp</result>
        </action>

Yes friends i have made mistake in struts.xml file. Now please tell me how should i receive url parameter in prepare() method? http://www.myweb.com/updatebusinessinfo/23

我努力跟踪但没有工作

<action name="updatebusinessinfo/*" class="com.controller.UpdateBusinessDetails">
<param name="id">{1}</param>

            <interceptor-ref name="params"/>
            <!--
            <interceptor-ref name="prepare"/> 

            <interceptor-ref name="basicStack"/>
            -->

            <interceptor-ref name="fileUpload">
                    <param name="maximumSize">2097152</param>
                    <param name="allowedTypes">image/png,image/gif,image/jpeg,image/pjpeg</param>
            </interceptor-ref>
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <result name="success">businessinfo.jsp</result>
            <result name="input">businessinfo.jsp</result>
            <result name="error">businessinfo.jsp</result>
        </action>
问题回答

寻找关于准备拦截者的信息的人可能会对此问题有所帮助:

  • The DefaultStack in struts2 already includes Prepare interceptor, so if you include them both you will have 2 calls to prepare(). Normally you don t want that.
  • In DefaultStack the Prepare interceptor is called BEFORE the Params interceptor, so you won t have the request params in the prepare() method. If you wanted to do something with params there (fetch something from DB with an ID, for example) you won t be able.

Look here to see what the basic/default stack has in struts2: http://struts.apache.org/release/2.0.x/docs/struts-defaultxml.html

有一个“ params prepareParamsStack ”, 它在准备前和准备后使用 Params, 所以您准备了您的参数( ) 。

我们仍期待您提供更多细节, 说明您想要做什么? 您正在点击哪些 URL 、 配置信息, 以及您应用程序的其他信息 。

只有当您已经安装了预设界面时, 才会调用预设方法。 简而言之, 它是一种初始化方法, 使我们能够在实际重力工作开始之前做任何初始化工作 。

准备方法将被调用 执行方法之前。 我建议你通过 准备方法的操作 以及它是如何被堆叠实际调用。

类似的方式是,S2如果已经实施,将呼唤行动组的验证方法,并将根据方法内提供的执行情况验证数据。

这只是对流动的概述,我仍建议提供更多关于你背景的信息,以获得任何良好的投入。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签