`
SuperCustomer
  • 浏览: 110162 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

Struts2配置

阅读更多
<struts>

    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <!-- 请求后缀 -->
	<constant name="struts.action.extension" value="do,action"/>
    <!-- 上传文件上限 -->
	<constant name="struts.multipart.maxSize" value="10240000"/>
    <!-- 资源文件,value指定其前缀 -->
	<constant name="struts.custom.i18n.resources" value="native"/>
	<constant name="struts.objectFactory" value="spring"/>
	
	<include file="global.xml"/>

	<package name="begin" namespace="/begin" extends="struts-default">
		<action name="begin" class="action.ActionBegin"
			method="execute">
			<!-- 转发(默认视图) -->
			<result name="success" type="dispatcher">/index.jsp</result>
		</action>
	</package>

	<package name="view" namespace="/view" extends="struts-default">
		<!-- 全局视图 -->
		<global-results>
			<result name="global">/index.jsp</result>
		</global-results>
		<action name="redirect" class="action.ActionView"
			method="execute">
			<!-- 重定向(可带参数,访问action里面的属性) -->
			<result type="redirect">/index.jsp?id=${id}</result>
		</action>
		<action name="redirectAction">
			<!-- 重定向到action-->
			<result type="redirectAction">
				<!-- 指定命名空间和action名称,如果是同包则不需指定 -->
				<param name="actionName">begin</param>
				<param name="namespace">/begin</param>
			</result>
		</action>
		<action name="plainText">
			<!-- 查看源代码-->
			<result type="plainText">
				<!-- 指定路径和编码 -->
				<param name="location">/index.jsp</param>
				<param name="charSet">UTF-8</param>
			</result>
		</action>
		<!-- 不用定义视图,可访问全局视图 -->
		<action name="global" class="action.ActionView" method="global" />
	</package>
	
	<!-- 动态方法 -->
	<package name="dynamic" namespace="/dynamic"
		extends="struts-default">
		<action name="dynamic*" class="action.DynamicAction"
			method="{1}">
			<result name="success">/index.jsp</result>
		</action>
	</package>
	
	<!-- 拦截器 -->
	<package name="interceptor" namespace="/interceptor"
		extends="struts-default">
		<interceptors>
			<interceptor name="login" class="util.LoginInterceptor" />
			<interceptor-stack name="loginStack">
				<interceptor-ref name="defaultStack" />
				<interceptor-ref name="login" />
			</interceptor-stack>
		</interceptors>
		<action name="interceptor" class="action.InterceptorAction"
			method="execute">
			<interceptor-ref name="loginStack" />
			<result>/login.jsp</result>
		</action>
	</package>

</struts>
分享到:
评论

相关推荐

    struts2 配置dtd 自动提示

    在配置Struts2时,通常会使用一个名为`struts.xml`的配置文件,该文件定义了应用程序的行为和组件。为了在开发环境中获得更好的代码辅助和提示,我们需要使IDE(例如Eclipse)理解`struts.xml`文件的结构,这通常...

    Struts2配置详解

    ### Struts2配置详解 #### 一、总览 在深入了解Struts2的配置细节之前,我们先来简要概述一下Struts2框架的核心特点及其配置文件的基本结构。Struts2是一个基于MVC(Model-View-Controller)设计模式的Java Web...

    SSH笔记_Struts2配置

    总结,Struts2配置涉及多个方面,包括核心库的引入、配置文件的编写、Action、Result、Interceptor的定义以及与Spring的整合等。通过合理配置,可以构建出高效、灵活的Web应用。在实际项目中,应根据需求调整和优化...

    struts2配置文件

    在Struts2中,配置文件主要分为两个部分:`struts-default.xml`和用户自定义的配置文件,如`struts.xml`或`struts-config.xml`。这些XML文件定义了Action、结果类型、拦截器和包等元素,从而控制应用程序的行为。 *...

    struts2配置文件加载顺序

    1. **struts-default.xml**:这是Struts2的核心配置文件,位于`struts2-core.jar`库的`/org/apache/struts2/defaults`包内。它包含了框架的基本设置,如拦截器栈、默认Action配置等。 2. **struts-plugin.xml**:这...

    struts2 配置JSP时需要的jar

    在配置Struts2与Spring的整合时,我们需要`spring-context.jar`、`spring-webmvc-struts.jar`等,它们负责管理Bean、依赖注入以及与Struts2的集成。 5. **Hibernate ORM**:如果项目中使用Hibernate作为持久层框架...

    ·Struts2配置文件介绍 超级详细

    ### Struts2配置文件介绍 #### 一、Struts2的核心配置文件 在Struts2框架中,有多个重要的配置文件用于控制应用的行为与结构,其中最核心的是`struts.xml`文件。此外还包括`web.xml`、`struts.properties`、`...

    struts2配置文件详细说明

    配置文件在Struts2中起着至关重要的作用,它定义了框架的行为、动作映射、拦截器和其他关键设置。以下是Struts2配置文件的一些核心元素和属性的详细说明: 1. **配置文件结构**: Struts2的配置通常存储在一个名为...

    struts2 Https 配置

    2. **Struts2配置**:在Struts2的应用中,我们需要确保Action请求被重定向到HTTPS。这可以通过在`struts.xml`配置文件中使用`&lt;constant&gt;`标签设置`struts.action.excludePattern`属性来实现。 ```xml ...

    struts2 配置文件

    ### Struts2 配置文件详解 #### 一、引言 在Struts2框架的应用开发过程中,配置文件起到了至关重要的作用。Struts2主要依赖于两种基于XML的配置文件:`web.xml` 和 `struts-config.xml`(通常命名为 `struts.xml`)...

    struts2配置文件改变位置问题

    在Struts2中,`struts.xml`文件是核心配置文件,它定义了动作、结果、拦截器等关键组件。在默认情况下,`struts.xml`通常位于`src/main/resources`或在Web应用中是`WEB-INF/classes`目录下。 在描述的问题中,...

    struts2配置文件传值中文乱码

    本文将围绕“Struts2配置文件传值中文乱码”这一主题,深入探讨其成因、解决方案以及相关的配置细节,旨在帮助开发者有效解决中文乱码问题,提升用户体验。 ### Struts2框架简介 Struts2是Apache组织下的一个开源...

    Struts2 配置文件

    配置SSH框架时关于Struts2的配置文件

    struts2配置文件详解

    ### Struts2配置文件详解 #### 一、引言 在Java Web开发中,Struts2框架因其灵活性和强大的功能而被广泛采用。Struts2框架的配置主要通过多个XML文件来实现,这些配置文件定义了应用程序的行为和结构。本文将详细...

    struts2配置环境需要的jar包

    2. **插件库**:Struts2提供了一系列插件,如`struts2-convention-plugin.jar`(用于自动配置)和`struts2-dojo-plugin.jar`(提供dojo相关的UI组件)。这些插件可以按需选择并添加到lib目录。 3. **依赖的第三方库...

    struts2配置示例

    这个“struts2配置示例”提供了一个基础的实现,展示了如何配置Struts2框架来处理用户的登录功能,使用OGNL(Object-Graph Navigation Language)表达式语言,并实现后台验证。下面我们将深入探讨这些关键知识点。 ...

    Struts2 配置文件手册

    配置文件在Struts2框架中起着至关重要的作用,它们定义了框架的行为、拦截器、对象工厂以及各种组件的配置。下面将详细介绍Struts2配置文件中的关键元素。 1) **struts-default.xml**: 这是Struts2框架默认加载的...

Global site tag (gtag.js) - Google Analytics