[英]How to use Struts2 convention without using any action class
In Struts2 we can define action without using action class in struts.xml
as follows: 在Struts2中,我们可以在不使用
struts.xml
动作类的情况下定义动作,如下所示:
<action name="error">
<result>/error.jsp</result>
</action>
In my application I am using struts2 convention
. 在我的应用程序中,我使用
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.
我有很多场景,我只想在不使用任何业务逻辑的情况下访问该页面。
My result path is not just a JSP. 我的结果路径不仅仅是一个JSP。 I am using tiles.
我正在使用瓷砖。 I am using code as follows:
我使用的代码如下:
@Action(value="homePage", results={@Result(name="success", location="homePage", type="tiles")})
You can place you jsp to the WEB-INF/content
this the default result path. 您可以将jsp放置到
WEB-INF/content
这个默认结果路径。 Also you can change this using a constant struts.convention.result.path
. 您也可以使用常量
struts.convention.result.path
更改此设置。 Convention plugin creates configuration from all JSPs there. Convention插件从那里的所有JSP创建配置。 So if you have
do-something.jsp
under result path you can use /do-something
in the browser to return this actionless result. 因此,如果你在结果路径下有
do-something.jsp
,你可以在浏览器中使用/do-something
来返回这个无效的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.