1

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.

Kirin Yao
  • 1,606
  • 2
  • 14
  • 21
  • 1
    Whats a user controller? Why not just use the parent package annotation? – Quaternion Mar 12 '13 at 22:20
  • Thanks @Quaternion, I followed your suggestion to see the document of annotations in convention-plugin, and find out `@ResultPath` annotation can help me. – Kirin Yao Mar 13 '13 at 06:10
  • Sorry I didn't read carefully enough, I'd assumed that you were creating the \user folder to apply an interceptor stack... I don't use the rest plugin, just conventions and so structure would look like: /user/list.jsp, /user/edit.jsp... that is the folder makes the entity implicit. I might have /user/list-error.jsp and /user/list-input.jsp. – Quaternion Mar 13 '13 at 17:32
  • Oh those folders are under /WEB-INF/content/ of course. I know this is asking a bit but as mentioned I'm not really familiar with the rest plugin, can you explain what you like about it? – Quaternion Mar 13 '13 at 18:14
  • @Quaternion Well, I'm newbie to struts world. I'd like to use rest plugin just to make the url clean so far. I know convention plugin can satisfy me, but I just want to have a try to rest. – Kirin Yao Mar 14 '13 at 06:02

1 Answers1

1

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.

Kirin Yao
  • 1,606
  • 2
  • 14
  • 21