How to use Struts2 convention without using any action class

故事扮演 提交于 2019-12-07 15:24:23

问题


In Struts2 we can define action without using action class in struts.xml as follows:

<action name="error">
    <result>/error.jsp</result>
</action>

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.

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")})

回答1:


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.



来源:https://stackoverflow.com/questions/25512148/how-to-use-struts2-convention-without-using-any-action-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!