问题
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