简体   繁体   中英

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:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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