问题
I have a little problem. Is it possible 'delete' index.html and create (to replace index.html) index.jsp? How?
I don't find any files (web.xml, glassfish-resource.xml) with the address to the home page (index.html) to change it (for index.jsp). I have not found an answer on the Internet...
Thanks for replies!
回答1:
What you need is to configure the welcome-file-list for your application. By default, it's index.html, which is why you don't find anything defining it.
Take a look at web.xml Deployment Descriptor Elements You basically need
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
回答2:
If you delete index.html then index.jsp will automatically take over for requests to http://yourserver/yourapp/
.
Do you have the problem of users having bookmarked http://yourserver/yourapp/index.html
itself so you need backwards compatibility? You can map index.jsp to respond to requests for index.html in web.xml:
<servlet>
<servlet-name>indexhtml</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>indexhtml</servlet-name>
<url-pattern>/index.html</url-pattern>
</servlet-mapping>
You could also use *.html there to have index.jsp respond to all requests for any .html:
<url-pattern>*.html</url-pattern>
来源:https://stackoverflow.com/questions/23705519/change-index-html-for-index-jsp-javaeeglassfish