简体   繁体   English

是否可以在struts2配置文件中编写任何没有任何结果的操作

[英]Is it possible to write any action without any result in struts2 config file

Is it possible to write any action without any result in struts2 config file ? 是否可以在struts2配置文件中编写任何没有任何结果的操作? like 喜欢

 < action name="showResult" class="com.mmi.webInterface.ShowResultAction"/>

but in stuts1.x it is possible to write any action without any forward result. 但是在stuts1.x中,可以编写任何没有任何前向结果的动作。 like 喜欢

< action path="/JsonResponse" type="com.mmi.webInterface.JsonResponseAction"
  validate="false"/>

my question is that how can i write any action without any result in struts 2 config file? 我的问题是,如何在struts 2配置文件中没有任何结果的情况下编写任何操作? because i have to use Ajax on the same page so no need of any result in action. 因为我必须在同一页面上使用Ajax,所以不需要任何结果。

Yes you can write it like : 是的你可以这样写:

<action name="ActionName" class="ClassName" method="methodName" />

We are using such actions in our application, where there is no need to display a page as a result. 我们在应用程序中使用此类操作,因此无需显示页面。 It works fine. 它工作正常。

Specify dummy locations. 指定虚拟位置。 For example, 例如,

<action name="showResult" class="com.mmi.webInterface.ShowResultAction">
    <result name="success">dummy</result>
</action>

this should work. 这应该工作。

<action name="actionName" class="ClassName" method="methodName"> </action> <action name =“actionName”class =“ClassName”method =“methodName”> </ action>

The method methodName should be of type void else you'd get an error saying that no result is defined for this action. methodName方法的类型应为void,否则您将收到一条错误消息,指出没有为此操作定义任何结果。

hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM