Я пытаюсь получить http://localhost:8080/test для сопоставления со страницей index.jsp.
Файл jsp хранится в папке:
/web-inf/jsp/index.jsp
что у меня до сих пор:
@Controller
public class HomeController {
@RequestMapping(value = "/test")
public String Test(){
return "index";
}
}
Мой 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">
<!-- Handles all requests into the application -->
<servlet>
<servlet-name>springmvc1</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Maps all /app requests to the DispatcherServlet for handling -->
<servlet-mapping>
<servlet-name>springmvc1</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
И мой springmvc1-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
- DispatcherServlet application context for PetClinic's web tier.
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">
<context:component-scan base-package="com.example.web"/>
<!--
- The BeanNameViewResolver is used to pick up the visits view name (below).
- It has the order property set to 2, which means that this will
- be the first view resolver to be used after the delegating content
- negotiating view resolver.
-->
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="1"/>
<!--
- This bean configures the 'prefix' and 'suffix' properties of
- InternalResourceViewResolver, which resolves logical view names
- returned by Controllers. For example, a logical view name of "vets"
- will be mapped to "/WEB-INF/jsp/vets.jsp".
-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" p:order="2"/>
</beans>
Я получаю сообщение об ошибке:
HTTP Status 404 - Servlet springmvc1 is not available
type Status report
message Servlet springmvc1 is not available
description The requested resource (Servlet springmvc1 is not available) is not available.
В чем может быть проблема?
Apache Tomcat/6.0.24
Вот вывод, который выдает сервер:
Feb 9, 2010 11:14:03 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_17\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;E:\Program Files\CodeSmith\v4.1\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;E:\Program Files\QuickTime\QTSystem\;E:\Program Files\TortoiseSVN\bin;C:\Documents and Settings\Administrator\My Documents\Downloads\nant-0.85-rc4-bin\nant-0.85-rc4;C:\Program Files\CodeSmith\v5.1\;%JAVA_HOME%\bin;%M2%;e:\program files\jetbrains\intellij idea 9.0.1\jre\jre\bin
Feb 9, 2010 11:14:03 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Feb 9, 2010 11:14:03 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 377 ms
Feb 9, 2010 11:14:03 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 9, 2010 11:14:03 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Feb 9, 2010 11:14:03 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
Feb 9, 2010 11:14:03 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Feb 9, 2010 11:14:03 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Feb 9, 2010 11:14:03 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
Feb 9, 2010 11:14:04 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
Feb 9, 2010 11:14:04 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Feb 9, 2010 11:14:04 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Feb 9, 2010 11:14:04 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31 config=null
Feb 9, 2010 11:14:04 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 623 ms
Connected to server
Обновление журнала tomcat
Кажется, что файл журнала tomcat не обновляется сразу, я думаю, он сбрасывается за несколько минут?
Ниже проблема:
Feb 9, 2010 11:14:03 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1484)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
Строка в том, что у меня есть spring 3.0 rc3
в моей папке 'external library' в IntelliJ. Кроме того, если я пойду и введу org.springframework.web.servlet.DispatcherServlet
intellisense, произойдет автозаполнение, которое, как я предполагаю, означает, что библиотека выбирается как часть проекта.