我在這裏讀取Deploy tomcat application to root in openshift,通過將.war文件重命名爲ROOT.war,您將可以通過鍵入此命令來訪問您的網站:http://app-domain.rhcloud.com/。所以我將它重命名爲root.war,但仍然沒有改變。我還是要鍵入http://app-domain.rhcloud.com/name-of-war-file將我的.war文件重命名爲ROOT.war,但仍需輸入全名+/appname
這是我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
`<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="false">
<display-name>Advanced Mappings Demo Application</display-name>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/WEB-INF/jsp/base.jspf</include-prelude>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
<default-content-type>text/html</default-content-type>
</jsp-property-group>
</jsp-config>
<session-config>
<session-timeout>30</session-timeout>
<cookie-config>
<http-only>true</http-only>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
這是我onStartUp方法(我將其配置編程):
@Override
public void onStartup(ServletContext container) throws ServletException
{
AnnotationConfigWebApplicationContext rootContext =
new AnnotationConfigWebApplicationContext();
rootContext.register(RootContextConfiguration.class);
container.addListener(new ContextLoaderListener(rootContext));
AnnotationConfigWebApplicationContext servletContext =
new AnnotationConfigWebApplicationContext();
servletContext.register(WebServletContextConfiguration.class);
ServletRegistration.Dynamic dispatcher = container.addServlet(
"springDispatcher", new DispatcherServlet(servletContext)
);
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
container.getServletRegistration("default").addMapping("/resources/*", "*.css", "*.js", "*.png", "*.gif", "*.jpg");
}
這是日誌我的應用程序在部署時:
Openshift logs after restarting my application via Eclipse
你有沒有把它命名爲'ROOT.war'或'root.war'(區分大小寫;你提你的問題中兩種款式)?有沒有任何部署錯誤? –
@JiriFiala感謝您檢視我的問題。我將它命名爲ROOT.war。沒有任何部署錯誤。沒有。我在原始帖子中粘貼了日誌消息。我重新啓動了我的應用程序,查看是否有任何部署錯誤。 –
@JiriFiala我的問題解決了!檢查答案xD –