【问题标题】:welcome-file does not work in WebLogic欢迎文件在 WebLogic 中不起作用
【发布时间】:2014-06-20 20:49:38
【问题描述】:

当我在 WebLogic 上部署我的 Web 应用程序 (Spring MVC) 时,欢迎页面不会使用默认 URL http://my.site.com/myApp 启动。我在主目录下有我的欢迎页面,我在 web.xml 中设置如下。

<welcome-file-list>
    <welcome-file>/home/index.html</welcome-file>
</welcome-file-list>

我可以使用完整的 URL http://my.site.com/myApp/home/index.html 访问该页面。

另外,如果我将 index.html 直接放在根目录下并按如下方式更新 web.xml,欢迎页面将使用默认 URL 启动

<welcome-file>/index.html</welcome-file>

我应该怎么做才能使默认URL启动主目录下的index.html?

这是 web.xml 和 applicationContext.xml 中的代码。

web.xml:

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/applicationContext.xml</param-value>
    </init-param>
 <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
     <servlet-name>appServlet</servlet-name>
     <url-pattern>/</url-pattern>
 </servlet-mapping>

applicationContext.xml:

  <mvc:default-servlet-handler/>

【问题讨论】:

  • 你确定这不是 Spring MVC 的 Web Filter 的问题吗?

标签: spring weblogic


【解决方案1】:

我认为它与前导斜杠有关。您是否尝试过简单地使用home/index.html 而不是/home/index.html

这个用户问了同样的问题,但是没有斜线:can-i-set-tomcat-with-a-welcome-file-in-a-subfolder

Another discussion on the same topic:

【讨论】:

  • 我尝试使用 home/index.html 而不是 /home/index.html。它没有用。
【解决方案2】:

我也遇到了同样的问题。

确保您尝试显示的文件位于 web-inf 文件夹。

weblogic.xml 文件中有一些可用的配置,但似乎都不起作用。我认为这是一项安全功能或其他不确定究竟是什么。

在我的情况下,调度程序 servlet 正在捕获空请求并显示未找到映射。也许您可以为它创建一个控制器映射并完成它。

有趣的是,同样的事情在 tomcat 7 中也能完美运行

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-11
  • 1970-01-01
  • 2021-06-16
相关资源
最近更新 更多