Spring MVC - Tiles - HTTP Status 503 - Servlet spring目前不可用

时间:2014-01-03 00:51:09

标签: java spring jsp spring-mvc tiles2

我的作业是否以各种方式进行了尝试但仍然出现以下错误:

(当前错误)

HTTP Status 404 - 

description The requested resource is not available.

Jan 03, 2014 12:27:43 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /Spring3MVCDemo threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Jan 03, 2014 12:27:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 03, 2014 12:27:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 03, 2014 12:27:43 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 533 ms

(早期错误) * > HTTP状态503 - Servlet弹簧当前不可用 *

我正在尝试使用Tiles显示一个简单的Spring MVC页面。我正在用Spring MVC做手 - 第一次使用Tiles所以可能会有一些我不知道的简单错误。请求您提供帮助,提前感谢您的时间和建议

代码是: pom.xml - 从3到2.2的更新版本的瓷砖

<dependency>
  <groupId>jstl</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.apache.tiles</groupId>
  <artifactId>tiles-api</artifactId>
  <version>2.2.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.apache.tiles</groupId>
  <artifactId>tiles-core</artifactId>
  <version>2.2.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.apache.tiles</groupId>
  <artifactId>tiles-jsp</artifactId>
  <version>2.2.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.apache.tiles</groupId>
  <artifactId>tiles-servlet</artifactId>
  <version>2.2.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.apache.tiles</groupId>
  <artifactId>tiles-template</artifactId>
  <version>2.2.2</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.5</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>3.1.2.RELEASE</version>
  <scope>compile</scope>
</dependency>

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">

    <display-name>Spring3MVC</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

调度-servlet.xml中

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles.xml</value>
            </list>
        </property>
    </bean>

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>

</beans>

tiles.xml

<!--?xml version="1.0" encoding="UTF-8"?-->
<tiles-definitions>

 <definition name="baseLayout" template="/jsp/layout/layout.jsp">
  <put-attribute name="title" value="My site" />
  <put-attribute name="header" value="/jsp/layout/header.jsp" />
  <put-attribute name="navigation" value="/jsp/layout/navigation.jsp" />
  <put-attribute name="body" value="" />
  <put-attribute name="footer" value="/jsp/layout/footer.jsp" />
 </definition>

 <definition name="login" extends="baseLayout">
  <put-attribute name="title" value="My site : Login" />
  <put-attribute name="navigation" value="" />
  <put-attribute name="body" value="/jsp/login.jsp" />
 </definition>

 <definition name="welcome" extends="baseLayout">
  <put-attribute name="title" value="My site : Welcome" />
  <put-attribute name="body" value="/jsp/welcome.jsp" />
 </definition>

</tiles-definitions>

WelcomeController.java

package com.web.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class WelcomeController
{
 @RequestMapping("/welcome")
 public String welcome()
 {
  return "welcome";
 }
}

layout.jsp

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
<head>
<title><tiles:insertAttribute name="title" ignore="true" /></title>
<script type="text/javascript" src="js/sivalabs.js"></script>
</head>
<body>

    <table border="1" style="border-collapse: collapse;" cellpadding="2"
        cellspacing="2" align="center" width="800">
        <tbody>
            <tr>
                <td height="30" colspan="2"><tiles:insertAttribute
                        name="header" /></td>
            </tr>
            <tr>
                <td width="150" height="450" valign="top"><tiles:insertAttribute
                        name="navigation" /></td>
                <td valign="top" width="650"><tiles:insertAttribute name="body" />

                </td>
            </tr>
            <tr>
                <td height="30" colspan="2"><tiles:insertAttribute
                        name="footer" /></td>
            </tr>
        </tbody>
    </table>
</body>
</html>

header.jsp中

<h2>Welcome to mysite</h2>

footer.jsp中

Copyright 2013

navigation.jsp

<p>
    <a href="createUser.do">Create User</a>
</p>
<p>
    <a href="listUsers.do">View Users</a>
</p>
<p>
    <a href="logout.do">Logout</a>
</p>

的login.jsp

<h2>Login page</h2>

的welcome.jsp

<h2>Welcome to SpringMVC+Tiles Sample Application </h2>

0 个答案:

没有答案