`
applefeng_52
  • 浏览: 11233 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Struts2配置文件-struts.xml

阅读更多
struts.xml配置文件结构如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<bean class="" name="" scope="" optional="" static="" type=""></bean>
<constant name="" value="" ></constant>
<include file="" ></include>
<package name="" namespace="" extends="" abstract="" externalReferenceResolver="">
	<action name="" class="" converter="" method=""></action>
	<default-action-ref name=""></default-action-ref>
	<default-class-ref class=""></default-class-ref>
	<default-interceptor-ref name=""></default-interceptor-ref>
	<global-exception-mappings>
		<exception-mapping result="" exception="" name="">
			<param name=""></param>
		</exception-mapping>
	</global-exception-mappings>
	<global-results>
		<result name="" type=""><param name=""></param></result>
	</global-results>
	<interceptors>
		<interceptor name="" class="">
			<param name=""></param>
		</interceptor>
		<interceptor-stack name="">
			<interceptor-ref name="">
				<param name=""></param>
			</interceptor-ref>
		</interceptor-stack>
	</interceptors>
	<result-types>
		<result-type name="" class="" default="false">
			<param name=""></param>
		</result-type>
	</result-types>
</package>
</struts>

1、bean节点
引用
http://struts.apache.org/2.x/docs/bean-configuration.html
Attribute Required Description 
class yes the name of the bean class 
type no the primary Java interface this class implements 
name no the unique name of this bean; must be unique among other beans that specify the same type 
scope no the scope of the bean; must be either default, singleton, request, session, thread 
static  no whether to inject static methods or not; shouldn't be true when the type is specified 
optional no whether the bean is optional or not 

bean元素需要class属性指定要被创建或者使用的java类,一个java bean1可能是以下两种:
a、被框架的容器创建然后注入到框架的内部对象
       对象注入方式,通常伴随着type属性,告诉容器这个java bean实现了哪个接口
b、使用值注入到自身的静态方法中
      值注入方式,对于允许不是容器创建的对象去接收框架的常量来说是不错的.对象使用值注入必须定义静态属性



分享到:
评论

相关推荐

    struts-config.xml struts标准配置文件 struts-config

    struts-config.xml struts标准配置文件 struts-config

    Struts框架中struts-config.xml文件配置小结

    而在Struts框架中,`struts-config.xml`文件扮演着至关重要的角色,它是Struts框架的核心配置文件,用于配置应用程序的各种行为和组件。本文将对`struts-config.xml`中的关键元素进行详细解析,并结合实际示例来帮助...

    struts2-json-plugin-2.3.8.jar

    在实际开发中,为了使用这个插件,你需要将`struts2-json-plugin-2.3.8.jar`文件放入项目的类路径(classpath)下,然后在Struts2的配置文件(通常为struts.xml)中启用JSON插件。在Action类中,定义返回JSON数据的...

    struts-2.3.15.1-lib.zip官方jar包

    4. **配置更新**:根据官方文档更新配置文件,如struts.xml或web.xml,以适应新版本的要求。 5. **测试**:升级后,进行详尽的功能测试和安全性测试,确保所有功能正常且没有新的安全漏洞引入。 6. **监控**:升级...

    SSH\\others\\struts2-spring-plugin-2.2.1.jar

    在使用Struts2 Spring Plugin时,开发者需要在Struts配置文件(struts.xml)中添加必要的配置,声明插件并指定Spring应用上下文的位置。这样,当Struts2框架处理请求时,它会查找并使用Spring容器中的Action实例。 ...

    struts2-core-2.0.12.jar

    配置文件** Struts2的配置主要在struts.xml文件中进行,这里定义了Action的映射、结果类型、拦截器栈等。开发者可以通过XML或注解方式来配置Action,使应用更加灵活。 **4. 拦截器(Interceptors)** 拦截器是...

    配置struts--config.xml详解

    在 Struts 应用程序中,`struts-config.xml` 文件是核心配置文件,它定义了应用的行为、控制器(Actions)、数据源(Form Beans)以及视图(JSP 页面)之间的关系。本文将深入探讨 `struts-config.xml` 的主要元素和...

    Struts2的DTD配置文件struts-2.3.dtd

    在Struts2中,`struts.xml`是核心配置文件,它定义了应用的行为、动作、结果和其他组件。为了在Eclipse这样的集成开发环境中获得代码提示和自动完成,我们需要引入DTD(文档类型定义)文件,例如`struts-2.3.dtd`。 ...

    struts2-json-plugin-2.1.8.1.jar

    "struts-plugin.xml"是Struts2插件的核心配置文件,它告诉Struts框架如何加载和使用这个插件。在这个文件中,开发者可以配置插件的启动顺序、Action的映射以及插件提供的拦截器等。对于JSON插件,这里可能包含关于...

    struts-2.0.11.2-lib

    - 使用`struts.xml`或`struts-default.xml`等配置文件来配置Action、结果页面和拦截器栈。 6. **安全性**: - Struts2.0.11.2版本在安全方面已经进行了多次优化,但依然需要注意其漏洞,例如著名的OGNL注入漏洞,...

    struts2版本 2.1.6 必须的jar包 和 web.xml 文件的修改

    在本文中,我们将深入探讨Struts2版本2.1.6中的核心jar包以及如何调整`web.xml`配置文件以实现正确部署。 首先,Struts2的核心jar包是框架运行的基础,它们提供了Action映射、拦截器、结果类型和其他关键功能。对于...

    struts2-sitemesh-plugin-2.2.1.1.jarstruts2

    2. 在`struts.xml`配置文件中启用插件: ```xml &lt;constant name="struts.plugin.packages" value="org.apache.struts2.sitemesh"/&gt; ``` 3. 配置Sitemesh的全局装饰器(可选): 在`web.xml`中添加以下配置: ``...

    struts-2.2.3.1-lib.zip

    5. **配置文件**:Struts 2的配置通常在`struts.xml`文件中进行,定义Action、Result和拦截器链。此外,还可以使用注解来减少XML配置。 6. **Action与Result**:Action是处理用户请求的业务逻辑组件,Result是...

    struts-2.3.31-all.zip

    5. **注解支持**:Struts2支持使用注解进行配置,减少了XML配置文件的使用,提高了开发效率。 6. **Freemarker和JSP视图技术**:Struts2可以与Freemarker或JSP一起工作,用于渲染视图。Freemarker是一种模板语言,...

    struts2-core-2.1.8.1 xwork-core-2.1.6源码

    4. **配置管理(Configuration Manager)**:Struts2的配置管理器负责读取配置文件(如struts.xml),并将配置信息加载到内存中。这部分代码主要位于`com.opensymphony.xwork2.config`包下,包括`Configuration`接口...

    struts-2.1.8.1-all.zip完整jar包

    - **struts-2.1.7.dtd、struts-2.1.dtd、struts-2.0.dtd**:这些是DTD(Document Type Definition)文件,定义了Struts配置文件的结构和规则,帮助XML解析器验证struts.xml的正确性。 - **struts2-dojo-plugin-2.1...

    struts-2.5.30-lib.zip struts-2.5.30jar包

    2. **配置文件**:通常为`struts.xml`,用于定义Action、结果类型、拦截器栈等。 3. **拦截器**:拦截器是Struts 2的重要特性,它们在Action调用前后执行,可以实现事务管理、日志记录、权限验证等功能。 4. **结果...

    struts-1.2.9-lib.tar.gz

    在使用"struts-1.2.9-lib.tar.gz"时,开发者需要将这些库文件添加到项目的类路径中,然后按照Struts的配置规范进行项目设置,包括编写Action类、ActionForm、Struts配置文件等。这将帮助他们快速构建符合MVC原则的...

    struts-config.xml

    `struts-config.xml`是Struts框架的核心配置文件,它定义了应用的各个组件及其交互方式。下面将详细介绍这个配置文件的主要元素和子元素。 ### 主要元素 1. **`&lt;data-sources&gt;`**: 这个元素用于配置数据源,通常...

    struts-2.3.24.1-all.zip

    6. **struts-default.xml** 和 **struts-plugin.xml** 文件:默认的配置文件,定义了框架的行为和插件。 7. **LICENSE** 和 **NOTICE** 文件:包含了框架的许可信息和版权声明。 Struts 2.3.x系列在功能上提供了很...

Global site tag (gtag.js) - Google Analytics