- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
控制台向我抛出此错误
ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed
Line 23 in XML document from ServletContext resource[/WEB-INF/spring/appServlet/servlet-context.xml] is invalid
这是我的 servlet 上下文文件
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
<context:component-scan base-package="mvc.test.hib" />
</beans:bean>
我缺少什么?我对 spring/hibernate 编程很陌生,有些事情我仍然不太理解
编辑:附加详细信息,我正在使用 Spring 工具套件和默认的 MVC spring 模板项目。
最佳答案
您发布的文件只有 21 行,而您给出的错误消息表明第 23 行无效。假设您在发布文件时丢失了几个换行符,那么您似乎缺少 <beans:beans>
的结束标记。声明。将以下内容添加到文件末尾,xml 语法将有效。
</beans:beans>
如果您使用 IDE(例如 Eclipse)或具有内置 XML 验证的文本编辑器(例如带有 XML 工具插件的 Notepad++),您会发现编写 XML 会更容易。这将使您更容易、更快地找到语法错误。
关于java - ServletContext 资源中的 XML 文档无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32079661/
我有一个 JSP 网站,不是 Spring MVC,它有一个配置文件 web.xml。 我想要获取 web.xml 文件中的一些设置。 但是,我想从“源包”文件夹中的类中访问这些设置。 我知道我可以将
什么是ServletContext? 根据字面意思即Servlet上下文 服务器会为每一个工程创建一个对象,这个对象就是ServletContext对象,这个对象是 全局唯一的,工程内部的所
我有一个类别列表,这些类别需要存在于应用程序的ServletContext范围内,因为该列表将由每个 View 访问,并且不需要修改。 我尝试在BootStrap.groovy的init方法中设置一个
ServletContext 是否在请求期间更新。例如我有这个代码: public void action(@Context ServletContext context) { Thread.sl
我正在将一些JSF代码从一个项目迁移到另一个项目,突然在我的新项目中ServletContext.TEMPDIR值失败了。我已经遍历了大多数文件,但这是唯一的错误,我不确定该在哪里修复。 tempdi
我正在尝试从服务访问servletContext(应用程序上下文)到集成测试中。 以下是我尝试让它进入我的集成测试的方法: import org.codehaus.groovy.grails.web.
我有 .NET 背景,正在尝试一些 Java(Servlet/JSP)基础知识。在.NET中,我们有ViewState、Session、Application变量。据我所知,Application 变
属性 repository 返回 null。 public class BaseServlet extends HttpServlet { protected MyPersistentMana
因此,我正在尝试建立一个在应用程序的多次使用(页面访问)中保持持久的 Mongo 连接。我厌倦了测试期间建立的所有这些连接,并且我想通过拥有单个持久连接来使用正确的过程。最佳实践等等。 这是我所拥有的
我正在我的 ServletContext 中存储一个 HashMap 对象。但是多个请求线程正在读取和修改这个 HashMap。 因为我相信 ServletContext 对象在请求线程之间共享,所以
您能否解释一下如何在我的Application 的子类中获取ServletContext 实例?可能吗?我试过像下面的代码片段那样做,但它似乎不起作用 - ctx 未设置: import javax.
我正在尝试手动引导 dispatcherservlet 作为练习。代码是 ServletRegistration.Dynamic dispatcher = container.addServlet(
这里的前提是,我不允许在这个网站上使用JavaScript或Cookies。 但是,我不想在每项至少需要密码 15-30 分钟的基本任务中询问用户密码。 我也不喜欢将密码保存到临时文件中,以防程序死掉
如果我使用 ../,为什么 ServletContext#getRealPath() 不会返回正确的路径 此代码有效:- System.out.println(context.getRealPath(
我正在使用上下文来共享登录 session 。我使用 setAttibute 函数。我知道 HttpSession 具有设置最大超时时间的属性。 是否可以以类似的方式设置上下文属性? ServletC
ServletConfig 和 ServletContext 接口(interface)有什么区别? 最佳答案 ServletConfig 参数是为特定 servlet 指定的,其他 servlet
我想听听你的意见。我正在开发一个 Servlet,它必须签署发送到端点的请求。 为了避免从服务器的 keystore 文件中读取、加载它并获取私钥,我在实现 ServletContextListene
我正在寻找一种方法将一些数据从数据库加载到 HashMap 中,并使该映射可用于所有根资源类和一些其他提供程序类(更准确地说是 ContainerRequestFilter 的实现)。我找到并实现了一
是否可以使用此API获取远程资源:ServletContext.getResourceAsStream() 例如:ServletContext.getResourceAsStream("http://
我的 RemoteServiceServlet 的日志输出(GWT) 在使用 getServletContext().log("anything"); 时不会显示在日志文件或标准输出中 对于依赖注入(
我是一名优秀的程序员,十分优秀!