Struts 2 + Spring 2 + JPA + AJAX (一)

本文档提供了一套详细的步骤来帮助读者从零开始搭建一个基于Tomcat和MySQL的应用程序。内容包括安装配置Tomcat和MySQL、创建数据库及表格、获取项目代码、使用Maven进行依赖管理和构建、手动创建Eclipse项目等。此外还介绍了如何通过Struts2、Spring框架、Hibernate等技术实现业务逻辑。
* Prerequisites
o Tomcat
o MySql
* Get the code
o Show me the code
o The maven way
* Doing it yourself
o Create Eclipse project
o Dependencies
o Domain
o Person service.
o JPA configuration
o Spring
o Struts
o The pages
o Validation
* Using Toplink Essentials instead of Hibernate
* References

Prerequisites

* Tomcat
* Eclipse
* MySQL Server (MySQL licensing policy)

Tomcat

Install Tomcat before going forward. See Tomcat's installation guide if you have any problem installing it.
MySql

Install and configure MySql. Create a database named "quickstart" and run the script below to create the "Person" table. Later, on applicationContext.xml, we'll use 'root' as the user name and password for the database, remember to replace those values with the right ones for your database.

CREATE TABLE 'quickstart'.'Person' (
'id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
'firstName' VARCHAR(45) NOT NULL,
'lastName' VARCHAR(45) NOT NULL,
PRIMARY KEY('id')
)
ENGINE = InnoDB;

Get the code
Show me the code

You can just download the zipped Eclipse project, add the required dependencies to the lib folder under the /WebContent/WEB-INF/lib folder (relative to project's root folder) and import it into Eclipse.
The maven way

To run the project this way you will need maven installed.

1. Download the zipped project
2. Download jta jar from here.
* Note that the Download Manager may save the file to your root drive, and it may give the file a .ZIP extension. You must rename the file to jta-1.1-classes.jar.
* If a later version is available, update the version references in the next step.
3. Install the jta jar file running:

$ mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.1 -Dpackaging=jar -Dfile=c:\path\to\jar\jta-1.1-classes.jar

4. Bear with me, we are almost there
5. cd into quickstart and run:

$ mvn jetty:run

6. Point your browser to http://localhost:8080/quickstart
7. To create an eclipse project run:

$ mvn eclipse:eclipse

or (to create web project for WTP):

mvn eclipse:eclipse -Dwtpversion=1.0

Doing it yourself
Create Eclipse project

1. Open Eclipse. Seriously, you need to open Eclipse.
2. Click File -> New -> Project. Under the "Web" folder, select "Dynamic Web Project" and click "Next".
3. Enter the project name, "quickstart" from here on. The project will be running inside Tomcat, so we need to create a server configuration for it.
1. Under "Target Runtime", click "New", select "Apache Tomcat 5.5" and click next.
2. Enter Tomcat's installation directory and select an installed JRE (1.5 is required)
4. Now you should be back to the project creation wizard, with Tomcat as your Target Runtime. Click "Next". Select "Dynamic Web Module" and "Java" facets, and click "Finish".

Dependencies

Your project should contain the folders "src", "build" and "WebContent". We are going to put all the required jars under "/WebContent/WEB-INF/lib". To add files to the "lib" folder, just copy them to ${workspace}\quickstart\WebContent\WEB-INF\lib, where ${workspace} is the location of your Eclipse workspace folder.

In the table, the version has been removed from the JAR files, since these may change in future milestone releases. Use whatever version is shipping with the indicated products.
JAR From License
xwork.jar Struts 2 Apache License
struts2-core.jar Struts 2
struts2-spring-plugin.jar Struts 2
ognl.jar Struts 2
freemarker.jar Struts 2
commons-logging-api.jar Struts 2
mysql-connector-java.jar MySql JDBC Driver MySQL licensing policy
spring.jar Spring 2.0 Apache License
antlr.jar Hibernate Core LGPL
asm.jar Hibernate Core
asm-attrs.jar Hibernate Core
cglib.jar Hibernate Core
dom4j.jar Hibernate Core
jdbc2_0-stdext.jar Hibernate Core
ehcache.jar Hibernate Core
hibernate3.jar Hibernate Core
xml-apis.jar Hibernate Core
commons-collections.jar Hibernate Core
ejb3-persistence.jar Hibernate Annotations LGPL
jta.jar Hibernate Annotations
hibernate-commons-annotations.jar Hibernate Annotations
hibernate-annotations.jar Hibernate Annotations
hibernate-entitymanager.jar Hibernate Entity Manager LGPL
javassist.jar Hibernate Entity Manager
jboss-archive-browsing.jar Hibernate Entity Manager

Right click on the project and select "Refresh" (to notify Eclipse of the jars that we just added).
内容概要:本文介绍了个基于MATLAB实现的无人机三维路径规划项目,采用蚁群算法(ACO)与多层感知机(MLP)相结合的混合模型(ACO-MLP)。该模型通过三维环境离散化建模,利用ACO进行全局路径搜索,并引入MLP对环境特征进行自适应学习与启发因子优化,实现路径的动态调整与多目标优化。项目解决了高维空间建模、动态障碍规避、局部最优陷阱、算法实时性及多目标权衡等关键技术难题,结合并行计算与参数自适应机制,提升了路径规划的智能性、安全性和工程适用性。文中提供了详细的模型架构、核心算法流程及MATLAB代码示例,涵盖空间建模、信息素更新、MLP训练与融合优化等关键步骤。; 适合人群:具备定MATLAB编程基础,熟悉智能优化算法与神经网络的高校学生、科研人员及从事无人机路径规划相关工作的工程师;适合从事智能无人系统、自动驾驶、机器人导航等领域的研究人员; 使用场景及目标:①应用于复杂三维环境下的无人机路径规划,如城市物流、灾害救援、军事侦察等场景;②实现飞行安全、能耗优化、路径平滑与实时避障等多目标协同优化;③为智能无人系统的自主决策与环境适应能力提供算法支持; 阅读建议:此资源结合理论模型与MATLAB实践,建议读者在理解ACO与MLP基本原理的基础上,结合代码示例进行仿真调试,重点关注ACO-MLP融合机制、多目标优化函数设计及参数自适应策略的实现,以深入掌握混合智能算法在工程中的应用方法。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值