Struts2学习笔记

[size=xx-large][color=orange][b]Struts2学习笔记[/b][/color][/size]

[color=red][b][size=medium]1.官网下载包[/size][/b][/color]

URL:http://struts.apache.org/
解压:/apps/struts2-blank.war
拷贝:struts.xml+web.xml+jar


[color=red][b][size=medium]2.struts.xml尖括号提示:[/size][/b][/color]

a.解压struts2-core-2.3.15.1.jar
b.windows--preferences--catalog--add:
解压文件中的dtd
URL
http://struts.apache.org/dtds/struts-2.3.dtd


[color=red][b][size=medium]3.工作流程图[/size][/b][/color]
[img]http://dl.iteye.com/upload/picture/pic/126749/d654611e-e1b7-3c8c-8999-956e1cbd7878.jpg[/img]

[color=red][b][size=medium]4.常量配置[/size][/b][/color]

struts.xml配置:
<constant name="struts.i18n.encoding" value="UTF-8"/>
该常量会覆盖struts2-core-2.3.15.jar包中/org.apache.struts2.default.properties中的值


[color=red][b][size=medium]5.jsp引入的标签s[/size][/b][/color]

<%@ taglib prefix="s" uri="/struts-tags" %>
这个uri对应该struts2-core-2.3.15.jar包中/META-INF/struts-tags.tld
该文件中:
<display-name>Struts Tags</display-name>
<tlib-version>2.3</tlib-version>
<short-name>s</short-name>
<uri>/struts-tags</uri>
处理类:<tag-class>org.apache.struts2.views.jsp.ActionTag</tag-class>
这个uri和此处的uri对应


[color=red][b][size=medium]5.struts.xml以及其他XML配置[/size][/b][/color]

<?xml version="1.0" encoding="UTF-8" ?>
1.struts.xml:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- true:开发模式,修改XML配置文件不用重启服务 -->
<constant name="struts.devMode" value="false" />
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<package name="default" namespace="/default" extends="struts-default">
<!-- 公共的跳转页面,所有Action都可以调用该result -->
<global-results>
<result name="error">/views/error.jsp</result>
</global-results>

<!-- 异常错误处理页面 -->
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
</package>

<!-- xml文件列表 -->
<include file="/default.xml"/>
<include file="/home.xml"/>
<include file="/userInfo.xml"/>
</struts>

extends="struts-default":继承了struts2-core-2.3.15.jar包中struts-default.xml的:
result结果集
Interceptor拦截器等


2.userInfo.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>
<package name="userInfoPackage" namespace="/" extends="default">
<action name="userInfo_*" class="com.momo.action.UserInfoAction" method="{1}">
<result name="success">/views/userInfo/userInfo_{1}_success.jsp</result>
<result name="fail">/views/userInfo/userInfo_{1}_fail.jsp</result>
</action>

<!-- 服务其跳转:页面 -->
<action name="dispatcher">
<result type="dispatcher">/views/userInfo/dispatcher.jsp</result>
</action>
<!-- 客户端跳转:页面 -->
<action name="redirect">
<result type="redirect">/views/userInfo/redirect.jsp</result>
</action>
<!-- 服务器跳转:Action方法 -->
<action name="chain">
<result type="chain">
<!-- 指定要跳转的Action位置 -->
<param name="namespace">/</param>
<param name="actionName">dispatcher</param>
</result>
</action>
<!-- 客户端跳转:Action方法 -->
<action name="redirectAction">
<result type="redirectAction">redirect</result>
</action>
</package>
</struts>

extends="default":可以共用namespace="default"目录中的结果集result


[color=red][b][size=medium]5.struts.xml配置前台UI标签样式[/size][/b][/color]

struts.xml:
<constant name="struts.ui.theme" value="simple"/><!-- UI标签类型(ajax,simple,xhtml,css_xhtml) -->

jsp:
<s:form>
<s:fielderror/>
</s:form>
html源码样式会采用最简单的,支持本地覆盖struts2-core-2.3.15.jar包中template中的模板也支持自定义模板


[color=red][b][size=medium]5.拦截器执行过程[/size][/b][/color]
[img]http://dl.iteye.com/upload/picture/pic/126757/25622056-628f-3fa6-8b16-773d1f99a3b3.jpg[/img]

模拟原理如下:
Main.java
ActionInvocation.java
Interceptor.java
FirstInterceptor.java
SecondInterceptor.java
Action.java


public class Main {
public static void main(String[] args) {
new ActionInvocation().invoke();
}
}


public class ActionInvocation {
List<Interceptor> interceptors = new ArrayList<Interceptor>();
int index = -1;
Action a = new Action();

public ActionInvocation() {
this.interceptors.add(new FirstInterceptor());
this.interceptors.add(new SecondInterceptor());

}

public void invoke() {
index ++;
if(index >= this.interceptors.size()) {
a.execute();
}else {

this.interceptors.get(index).intercept(this);
}
}
}


public interface Interceptor {
public void intercept(ActionInvocation invocation) ;
}


public class FirstInterceptor implements Interceptor {
public void intercept(ActionInvocation invocation) {
System.out.println(1);
invocation.invoke();
System.out.println(-1);
}
}


public class SecondInterceptor implements Interceptor {
public void intercept(ActionInvocation invocation) {
System.out.println(2);
invocation.invoke();
System.out.println(-2);
}
}


public class Action {
public void execute() {
System.out.println("execute!");
}
}



[color=red][b][size=medium]5.[/size][/b][/color]



[color=red][b][size=medium]5.[/size][/b][/color]



[color=red][b][size=medium]5.[/size][/b][/color]



[color=red][b][size=medium]5.[/size][/b][/color]



[color=red][b][size=medium]5.[/size][/b][/color]

【四轴飞行器】非线性三自由度四轴飞行器模拟器研究(Matlab代码实现)内容概要:本文围绕非线性三自由度四轴飞行器模拟器的研究展开,重点介绍基于Matlab代码实现的四轴飞行器动力学建模与仿真方法。研究构建了考虑非线性特性的飞行器数学模型,涵盖姿态动力学与运动学方程,实现了三自由度(滚转、俯仰、偏航)的精确模拟。文中详细阐述了系统建模过程、控制算法设计思路及仿真结果分析,帮助读者深入理解四轴飞行器的飞行动力学特性与控制机制;同时,该模拟器可用于算法验证、控制器设计与教学实验。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的高校学生、科研人员及无人机相关领域的工程技术人员,尤其适合从事飞行器建模、控制算法开发的研究生和初级研究人员。; 使用场景及目标:①用于四轴飞行器非线性动力学特性的学习与仿真验证;②作为控制器(如PID、LQR、MPC等)设计与测试的仿真平台;③支持无人机控制系统教学与科研项目开发,提升对姿态控制与系统仿真的理解。; 阅读建议:建议读者结合Matlab代码逐模块分析,重点关注动力学方程的推导与实现方式,动手运行并调试仿真程序,以加深对飞行器姿态控制过程的理解。同时可扩展为六自由度模型或加入外部干扰以增强仿真真实性。
基于分布式模型预测控制DMPC的多智能体点对点过渡轨迹生成研究(Matlab代码实现)内容概要:本文围绕“基于分布式模型预测控制(DMPC)的多智能体点对点过渡轨迹生成研究”展开,重点介绍如何利用DMPC方法实现多智能体系统在复杂环境下的协同轨迹规划与控制。文中结合Matlab代码实现,详细阐述了DMPC的基本原理、数学建模过程以及在多智能体系统中的具体应用,涵盖点对点转移、避障处理、状态约束与通信拓扑等关键技术环节。研究强调算法的分布式特性,提升系统的可扩展性与鲁棒性,适用于多无人机、无人车编队等场景。同时,文档列举了大量相关科研方向与代码资源,展示了DMPC在路径规划、协同控制、电力系统、信号处理等多领域的广泛应用。; 适合人群:具备一定自动化、控制理论或机器人学基础的研究生、科研人员及从事智能系统开发的工程技术人员;熟悉Matlab/Simulink仿真环境,对多智能体协同控制、优化算法有一定兴趣或研究需求的人员。; 使用场景及目标:①用于多智能体系统的轨迹生成与协同控制研究,如无人机集群、无人驾驶车队等;②作为DMPC算法学习与仿真实践的参考资料,帮助理解分布式优化与模型预测控制的结合机制;③支撑科研论文复现、毕业设计或项目开发中的算法验证与性能对比。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注DMPC的优化建模、约束处理与信息交互机制;按文档结构逐步学习,同时参考文中提及的路径规划、协同控制等相关案例,加深对分布式控制系统的整体理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值