Udit Mishra
Udit Mishra

Reputation: 140

How to load the first page without listing it in <welcome-file-list> in Struts 2?

Whenever my web application starts, I need to provide the welcome, or index, or first file inside the <welcome-file-list>.

But, can Struts 2 load a first page that comes through the engine instead of listing it in <welcome-file-list>?

There after, I am able to post requests to the Struts engine using actions in <s:form> or in <s:a> tags. I want to load the index page or the first page of my web application through Struts 2, i.e. the initial request itself should pass through the engine, and the response should come from the engine only, is it possible?

Upvotes: 0

Views: 191

Answers (1)

Roman C
Roman C

Reputation: 1

If you are using Struts tags inside JSP page, either it welcome file listed or not it should be a dispatcher result of an action. Welcome file list files could be handled by the web container if you navigate to the folder of your web content hierarchy and there's a welcome file inside it, and there's no action mapped to that URL. In this case you cannot use struts tags inside the welcome file because you are trying to run it without associated filter, or the struts2 filter is already handled another request.

See the examples of Hello World application or Hello World using Struts2 that would show you how to create action configuration that utilize an index action or use actionless results using Convention Hello World example.

Upvotes: 1

Related Questions