在Netbeans中部署Spring MVC 3.1应用程序

时间:2013-11-13 04:54:23

标签: spring spring-mvc spring-webflow

嗨发生我正在使用注释在netbeans中执行HElloWorld,但每次我部署glassfish都会丢失此错误: java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:org.apache.catalina.LifecycleException:org.xml.sax.SAXParseException; lineNumber:13; columnNumber:54; El prefijo“context”para el elemento“context:component-scan”noestáenlazado.. Consulte server.log paraobtenermásinformación。

这是我的调度员 - servlet`

<context:component-scan base-package="Controllers" />
<mvc:annotation-driven />

<bean
id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >

<property
    name="viewClass"
    value="org.springframework.web.servlet.view.JstlView" />

<property
    name="suffix"
    value=".jsp" />
</bean>

这是我的web.xml

<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">
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener- class>
</listener>
<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>

这是我的控制器

package Controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/hello.htm")
public class helloController {



@RequestMapping(method=RequestMethod.GET)
public ModelAndView helloWorld(){

ModelAndView model = new ModelAndView("hello");

return model;
}  }  

如你所见,非常基本,真的不知道错误在哪里。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

“org.xml.sax.SAXParseException; lineNumber:13; columnNumber:54;“这个提示显示xml文件错误的”上下文“。你是否配置了xml文件描述如 <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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">