如何在不使用任何操作类的情况下使用Struts2约定 [英] How to use Struts2 convention without using any action class
问题描述
在Struts2中,我们可以在 struts.xml
中不使用动作类来定义动作,如下所示:
In Struts2 we can define action without using action class in struts.xml
as follows:
<action name="error">
<result>/error.jsp</result>
</action>
在我的应用程序中,我使用 struts2约定
。在这种情况下如何避免编写动作类。我有很多场景,我只想在不使用任何业务逻辑的情况下访问该页面。
In my application I am using struts2 convention
. In this case how to avoid writing action classes. I have many scenarios where I just want to go to the page without using any business logic.
我的结果路径不仅仅是一个JSP。我正在使用瓷砖。我使用的代码如下:
My result path is not just a JSP. I am using tiles. I am using code as follows:
@Action(value="homePage", results={@Result(name="success", location="homePage", type="tiles")})
推荐答案
您可以将jsp放到 WEB-INF / content
这是默认结果路径。您也可以使用常量 struts.convention.result.path
更改此设置。 Convention插件从那里的所有JSP创建配置。因此,如果您在结果路径下有 do-something.jsp
,则可以在浏览器中使用 / do-something
返回这无动于衷的结果。
You can place you jsp to the WEB-INF/content
this the default result path. Also you can change this using a constant struts.convention.result.path
. Convention plugin creates configuration from all JSPs there. So if you have do-something.jsp
under result path you can use /do-something
in the browser to return this actionless result.
这篇关于如何在不使用任何操作类的情况下使用Struts2约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!