How can I set the welcome page to a struts action?

后端 未结 15 1975
天涯浪人
天涯浪人 2020-11-29 20:15

I have a struts-based webapp, and I would like the default \"welcome\" page to be an action. The only solutions I have found to this seem to be variations on making the welc

15条回答
  •  醉梦人生
    2020-11-29 21:09

    "Surely there's a better way!"

    There isn't. Servlet specifications (Java Servlet Specification 2.4, "SRV.9.10 Welcome Files" for instance) state:

    The purpose of this mechanism is to allow the deployer to specify an ordered list of partial URIs for the container to use for appending to URIs when there is a request for a URI that corresponds to a directory entry in the WAR not mapped to a Web component.

    You can't map Struts on '/', because Struts kind of require to work with a file extension. So you're left to use an implicitely mapped component, such as a JSP or a static file. All the other solutions are just hacks. So keep your solution, it's perfectly readable and maintainable, don't bother looking further.

提交回复
热议问题