嗨碰巧我在 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;
} }
如您所见,这是非常基本的,并且真的不知道错误在哪里。任何人都可以帮助我吗?