Вопрос

Hi happens that im doing a HElloWorld in netbeans using annotations but each time i deploy glassfish drops this Error: 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" no está enlazado.. Consulte server.log para obtener más información.

This is my dispatcher-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>

This is my 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>

And this is my controller

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;
}  }  

As you see is very basic and really dont know where the mistake is. Anybody can help me?

Это было полезно?

Решение

“org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 54;” this tip shows the xml file is wrong with "context".Are u config the xml file description such as <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">

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top