Glassfish 上下文根源问题
我正在尝试在 glassfish 服务器的根目录中部署 JSF-2 应用程序,以便 http://localhost:8080/
引导至我的欢迎页面。由于某种原因,当尝试配置它时,http://localhost:8080/
导致 glassfish 默认欢迎页面,而 http://localhost:8080//
导致我的。如果我转到 http://localhost:8080/
如何解决这个问题?
sun-web.xml:
<sun-web-app error-url="">
<context-root>/</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>
web.xml(减去安全约束和其他不相关的内容)
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<filter-mapping>
<filter-name>AlreadyLoggedInRedirectFilter</filter-name>
<url-pattern>/login.jsf</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<filter>
<filter-name>AlreadyLoggedInRedirectFilter</filter-name>
<filter-class>com.xdin.competence.jsf.util.AlreadyLoggedInRedirectFilter</filter-class>
</filter>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/viewExpired.jsf</location>
</error-page>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsf</form-login-page>
<form-error-page>/login.jsf</form-error-page>
</form-login-config>
</login-config>
顺便说一下,该应用程序不是服务器的默认应用程序,我只是希望将其部署在根。
I'm trying to deploy a JSF-2 application in the root of my glassfish server so that http://localhost:8080/
leads to my welcome page. For some reason when trying to configure this, http://localhost:8080/
leads to glassfish default welcome page while http://localhost:8080//
leads to mine. If I go to http://localhost:8080/<welcome-page>
it works, so the context-root seems to work in most cases, it's just the welcome page that has the wrong mapping somehow.
How to fix this?
sun-web.xml:
<sun-web-app error-url="">
<context-root>/</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>
web.xml (minus security constraints and other unrelated stuff)
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<filter-mapping>
<filter-name>AlreadyLoggedInRedirectFilter</filter-name>
<url-pattern>/login.jsf</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<filter>
<filter-name>AlreadyLoggedInRedirectFilter</filter-name>
<filter-class>com.xdin.competence.jsf.util.AlreadyLoggedInRedirectFilter</filter-class>
</filter>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/viewExpired.jsf</location>
</error-page>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsf</form-login-page>
<form-error-page>/login.jsf</form-error-page>
</form-login-config>
</login-config>
As a side note, the application is not the default application of the server, I just want it to be deployed in the root.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是玻璃鱼的一个特殊“功能”。请查看 如何部署 EAR 内的 WAR 作为 Glassfish 中的根 (/) 上下文?
顺便说一句:您使用的是哪个版本的 glassfish?您是否可以将您的应用程序更改为默认应用程序?
it's a special 'feature' from glassfish. Please check out the answers in How do you deploy a WAR that's inside an EAR as the root (/) context in Glassfish?
Btw: Which version of glassfish are you using? Is it possible for you to change your application to be the default application?