【发布时间】:2015-09-07 10:10:43
【问题描述】:
这是我的控制器:
@Controller
public class WebRedirectController {
@RequestMapping(value = "/welcome", method = RequestMethod.GET)
public String welcome() {
return "welcome";
}
@RequestMapping(value = "/redirect", method = RequestMethod.GET)
public String redirect() {
return "redirect:finalPage";
}
@RequestMapping(value = "/finalPage", method = RequestMethod.GET)
public String finalPage() {
return "final";
}
}
servletContext.xml:
<beans xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- Enable annotation driven controllers, validation etc... -->
<mvc:annotation-driven></mvc:annotation-driven>
<context:component-scan base-package="com.dineshonjava.controller">
</context:component-scan>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
id="viewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
我在运行应用程序时遇到此异常:
来自 ServletContext 资源 [/WEB-INF/config/sdnext-servlet.xml] 的 XML 文档中的第 10 行无效;嵌套异常是 org.xml.sax.SAXParseException;行号:10;列号:65; cvc-elt.1:找不到元素“beans”的声明。
请告诉我我在哪里做错了我试图解决这个问题但仍然无法解决请建议我。
【问题讨论】:
-
您遇到的错误与您提出的问题完全无关。检查你的 xml。检查您的类路径中是否有适当的 Spring 库。
-
paste.ofcode.org/HFVEJBgDjyU6pscDWmKdeL 这是 web.xml @ Sotirios Delimanolis
-
错误是指
sdnext-servlet.xml文件。交叉检查是否有效,如果仍然找不到错误,请在此处粘贴该文件, -
请把sdnext-servlet.xml的内容贴在这里。
标签: java spring model-view-controller