그래서 기본적으로 내 시스템에서 기본적인 Spring 3 MVC 예제를 실행하려고합니다. 그러나이 예는 고집 스럽습니다. 여기에 언급 된 단계를 따르고 있습니다. http://viralpatel.net/blogs/spring-3-mvc-create-hello-world-application-spring-3-mvc/Spring 3 Apache Tomcat 7.0에서 실행되지 않는 MVC 예제
매핑이 현명한 것으로 보입니다. 그러나 나는 일식 또는 Tomcat 서버에 아파치 톰캣 7.0에서 실행할 때 직접 나는 다음과 같은 오류가 발생합니다 :
**type** Status report
**message** /Spring3MVC/
**description** The requested resource is not available.
콘솔 로그는 다음과 같습니다
이Dec 5, 2012 1:13:04 PM 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\jre6\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\TortoiseSVN\bin;D:\apache-maven-2.2.1\bin;.
Dec 5, 2012 1:13:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Spring3MVC' did not find a matching property.
Dec 5, 2012 1:13:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 5, 2012 1:13:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 5, 2012 1:13:04 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 402 ms
Dec 5, 2012 1:13:04 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 5, 2012 1:13:04 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.33
Dec 5, 2012 1:13:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Dec 5, 2012 1:13:05 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Dec 5, 2012 1:13:05 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Dec 5, 2012 1:13:05 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
Dec 5, 2012 1:13:05 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization started
Dec 5, 2012 1:13:05 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Wed Dec 05 13:13:05 IST 2012]; root of context hierarchy
Dec 5, 2012 1:13:06 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
Dec 5, 2012 1:13:06 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.s[email protected]a0219e: defining beans [helloWorldController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,viewResolver,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
Dec 5, 2012 1:13:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello] onto handler 'helloWorldController'
Dec 5, 2012 1:13:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello.*] onto handler 'helloWorldController'
Dec 5, 2012 1:13:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello/] onto handler 'helloWorldController'
Dec 5, 2012 1:13:06 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization completed in 469 ms
Dec 5, 2012 1:13:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 5, 2012 1:13:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 5, 2012 1:13:06 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1554 ms
유일한 것은 내가 볼 수 있었다 이 경고에 atDec 5, 2012 1:13:04 PM을 언급했으나 응용 프로그램을 방해해서는 안됩니다.
웹-INF에서내 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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
WEB-INF에서 나의 봄-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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan
base-package="net.viralpatel.spring3.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
내 helloWorldController은 같다 다음 :
package net.viralpatel.spring3.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class HelloWorldController {
@RequestMapping("/hello")
public ModelAndView helloWorld() {
String message = "Hello World, Spring 3.0!";
return new ModelAndView("hello", "message", message);
}
}
마지막으로 내 index.jsp를 웹-INF에/내 Hello.jsp에가있는 동안 웹-INF/JSP
나는 봄에서 시작하고 있지만,이 응용 프로그램을 실행해야한다고 말할 수있는 한 멀리 있습니다. 또한 웹상의 다른 예를 비교해 보면 비슷한 구조를 가지고 있습니다. 서블릿에 대한 매핑이 없다는 오류를 검색하는 것은 사실이 아닙니다. 누군가가 거기에 해결책을 가지고 있기를 바랍니다. 사전에
감사합니다.
스프링 - 서블릿 이름을 dispatcher-servlet으로 변경하고 web.xml에서 해당 변경 사항을 적용한 후 앱이 작동하기 시작했습니다. – IndianNoob