0

嗨碰巧我在 netbeans 中使用注释做一个 HElloWorld 但每次我部署 glassfish 时都会丢弃这个错误:java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org .xml.sax.SAXParseException;行号:13;列号:54;El prefijo "context" para el elemento "context:component-scan" no está enlazado.. 请参阅 server.log para obtener más informationació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;
}  }  

如您所见,这是非常基本的,并且真的不知道错误在哪里。任何人都可以帮助我吗?

4

1 回答 1

0

“org.xml.sax.SAXParseException; 行号:13;列号:54;” 此提示显示 xml 文件与“context”错误。您是否配置了 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">

于 2013-11-22T06:31:53.620 回答