Glassfish 上下文根源问题

发布于 2024-11-06 02:24:45 字数 2604 浏览 2 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上芳菲 2024-11-13 02:24:45

这是玻璃鱼的一个特殊“功能”。请查看 如何部署 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文