I'm using struts2 + convention + rest to build my Web project. There are many jsp files in the content folder. So I want to classify them by folders. For example, I want to put user.jsp
, user-list.jsp
and user-edit.jsp
in \content\user
folder. And I must add Namespace
annotation to UserController
, as follow:
@Namespace("/user")
public class UserController
But if I do that, the url to access user.jsp
changes to localhost:8080\projectName\user\user
. I don't like so much user
int the url.
So my question is, can I change the default mapping rule to access user.jsp
by localhost:8080\projectName\user
? If I can't change it, then how to manage so much jsp files in \WEB-INF\content
folder?
Any help will be greatly appreciated.
I find out that the @ResultPath
annotation can solve my issue. So the code become as follows:
@ResultPath("/WEB-INF/content/user")
public class UserController
By doing this, I could access WEB-INF/content/user/user.jsp
file by url localhost:8080/projectName/user
.
I'm still wondering if there is any approach to change the default result path to the way of /WEB-INF/content/{controllerNamePrefix}
at a single position, instead of adding annotation to each controller class.