Struts配置详解:struts-config1.1.xml

需积分: 3 3 下载量 120 浏览量 更新于2024-09-17 收藏 17KB DOCX 举报
"struts-config1.1.xml 文件是 Apache Struts 框架的一个核心配置文件,用于定义应用的控制器行为和数据源配置。它遵循 Struts 1.1 的 DTD(Document Type Definition)规范,用于描述应用的各个组件和它们的交互方式。" 在 `struts-config.xml` 文件中,有以下几个关键知识点: 1. XML 文档结构:文件以 XML 格式编写,声明了 XML 版本和编码。DOCTYPE 声明指定了 Struts 配置的 DTD,该 DTD 定义了所有允许的元素和属性。 2. struts-config 根元素:`<struts-config>` 是整个配置文件的根节点,所有其他的配置元素都包含在这个元素内部。 3. data-sources 元素:`<data-sources>` 元素用于定义 web 应用程序中使用的数据源。在 Struts 1.x 中,虽然 Struts 主要是用于处理 MVC 模式的控制层,但也可以通过配置数据源来管理数据库连接。 4. data-source 子元素:`<data-source>` 用于创建具体的数据库连接池。每个 `data-source` 可以有多个,通过 `key` 属性区分不同的数据源。`type` 属性指定数据源实现的全限定类名,常见的包括 Poolman、Expresso、JDBCPool 和 DBCP。 5. set-property 子元素:`<set-property>` 用于设置数据源的各种属性,如自动提交 (`autoCommit`)、描述 (`description`)、驱动类 (`driverClass`)、最大连接数 (`maxCount`)、最小连接数 (`minCount`)、数据库用户名 (`user`) 和密码 (`password`),以及数据库 URL (`url`)。这些属性是配置数据源连接的关键参数。 例如,在提供的配置片段中,定义了一个名为 "firstOne" 的数据源,使用 `org.apache.commons.dbcp.BasicDataSource` 类作为实现,设置了自动提交为 true,并添加了一个简单的描述 "Hello!"。其他属性如数据库连接信息(用户、密码、URL 等)没有在示例中给出,但在实际配置中是必需的。 `struts-config1.1.xml` 文件是 Struts 1.x 框架中配置应用行为和数据源的重要文件,通过它可以定制请求处理逻辑、表单验证规则、动作映射以及数据源等核心功能,从而实现灵活的 MVC 应用程序开发。

我用Spring5的aop应用时报这个错误Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [D:\ecliple\web5\WEB-INF\applicationContext.xml]; nested exception is java.nio.file.NoSuchFileException: WEB-INF\applicationContext.xml,他说我的applicationContext.xml文件不存在,可是我明明有这个文件,另外我的web.xml需要更改吗<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <context-param> <param-name>contextConfigLocation </param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <display-name>Struts2</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/* </url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>

2023-05-30 上传

192.168.85.1 - - [26/Jun/2022:06:07:07 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 24 192.168.85.1 - - [26/Jun/2022:06:07:11 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 24 192.168.85.1 - - [26/Jun/2022:06:07:11 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 24 192.168.85.1 - - [26/Jun/2022:06:07:11 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 200 12925 192.168.85.1 - - [26/Jun/2022:06:07:11 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 200 12925 192.168.85.1 - - [26/Jun/2022:06:07:11 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 200 12925 192.168.85.1 - - [26/Jun/2022:06:07:11 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 200 14 192.168.85.1 - - [26/Jun/2022:06:08:06 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 15 192.168.85.1 - - [26/Jun/2022:06:08:16 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 1227 192.168.85.1 - - [26/Jun/2022:06:10:15 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 79 192.168.85.1 - - [26/Jun/2022:06:13:25 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 404 752 192.168.85.1 - - [26/Jun/2022:06:16:42 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 35 192.168.85.1 - - [26/Jun/2022:06:16:57 -0400] "GET //struts2-showcase/hhh.jsp HTTP/1.1" 403 642 192.168.85.1 - - [26/Jun/2022:06:18:55 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 35 192.168.85.1 - - [26/Jun/2022:06:19:02 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 35 192.168.85.1 - - [26/Jun/2022:06:19:09 -0400] "GET //struts2-showcase/hhh1.jsp HTTP/1.1" 403 642 192.168.85.1 - - [26/Jun/2022:06:19:34 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 400 192.168.85.1 - - [26/Jun/2022:06:20:37 -0400] "POST /struts2-showcase/index.action HTTP/1.1" 500 5 192.168.85.1 - - [26/Jun/2022:06:20:42 -0400] "GET //struts2-showcase/hhh1.jsp HTTP/1.1" 403 642 192.168.85.1 - - [26/Jun/2022:06:20:46 -0400] "GET //struts2-showcase/hhh.jsp HTTP/1.1" 403 642 192.168.85.1 - - [26/Jun/2022:06:20:51 -0400] "GET /struts2-showcase/hhh.jsp HTTP/1.1" 403 642

2023-07-12 上传