2015-05-28 19 views
0

要在tomcat中发布一个java-web应用程序,我将名为'demo-mvc'的项目复制到tomcat的webapps文件夹中。然后在chorme浏览器中访问“http://localhost:8080/demo-mvc/xx.jsp” Tomcat的,但它提示“请求的资源不可用”。我试过编辑server.xml如下如何在tomcat中发布java web项目

<Context docBase="D:\apache-tomcat-7.0.57\webapps\demo-mvc" path="/demo-mvc" reloadable="true" source="org.eclipse.jst.jee.server:website"/> 

最后它仍然没有没有effect.I感到困惑的问题出在哪里。

+0

难道应用程序无法启动在Tomcat中,即你是否在日志中获得任何堆栈跟踪? – seanhodges

+0

你复制后重新启动服务器吗? – Saif

+0

我已重新启动服务器 – luohao

回答

1

尝试从项目清理选项,清理项目,并确保您映射所有的资源

在web.xml的代码应该是这样的:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" 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_2_5.xsd"> 

    <!-- The definition of the Root Spring Container shared by all Servlets and Filters --> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/root-context.xml</param-value> 
    </context-param> 

    <!-- Creates the Spring Container shared by all Servlets and Filters --> 
    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <!-- Processes application requests --> 
    <servlet> 
     <servlet-name>appServlet</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/spring/appServlet/servlet-context.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> 

</web-app> 
相关问题