OA项目1:环境搭建之数据库创建与环境添加
首注:本学习教程为 传智播客汤阳光 一 指定数据库:Mysql database:oa 建库语句:create database oa default character set utf8 二 指定ide开发工具:MyEclipse 项目名称:新建web工程,名字为:OA,并设置项目工程编码:utf-8 环境所用主要技术框架:JU
首注:本学习教程为传智播客汤阳光
一 指定数据库:Mysql
database:oa
建库语句:create database oa default character set utf8
二 指定ide开发工具:MyEclipse
项目名称:新建web工程,名字为:OA,并设置项目工程编码:utf-8
环境所用主要技术框架:JUnit4,Struts2.3.15.1,Hibernate3.6,Spring2.5.6,jQuery,……
三 添加框架环境:
1.添加JUnit环境:
右击项目名称 --> Build Path --> Add Libraries --> JUnit,点击next,选择版本为JUnit 4,点击finish。完成JUnit环境添加。
2.添加Struts2.3.15.1环境:
添加jar包:
事先到官网下载好对应版本的项目环境,解压后打开进入apps文件夹里,用好压工具打开struts2-blank.war,点击WEB-INF,
将lib下面的jar包全部复制到我们OA项目的lib下面。
添加配置文件:
用好压工具打开struts2-blank.war,点击WEB-INF,将src --> java下面的struts.xml拷贝到我们OA项目的src下面。然后将
struts.xml里的内容修改为如下内容:
<span> 1</span> <span></span><span>xml version="1.0" encoding="UTF-8" </span><span>?></span> <span> 2</span> <span><span>DOCTYPE struts PUBLIC </span><span> 3</span> <span> "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" </span><span> 4</span> <span> "http://struts.apache.org/dtds/struts-2.3.dtd"</span><span>></span> <span> 5</span> <span> 6</span> <span><span>struts</span><span>></span> <span> 7</span> <span> 8</span> <span><!--</span><span> 设置为开发者模式 </span><span>--></span> <span> 9</span> <span><span>constant </span><span>name</span><span>="struts.devMode"</span><span> value</span><span>="true"</span> <span>/></span> <span>10</span> <span><!--</span><span> 把扩展名设置为.action,如name里的内容记不住,请在core包里的default.properties里面找 </span><span>--></span> <span>11</span> <span><span>constant </span><span>name</span><span>="struts.action.extension"</span><span> value</span><span>="action"</span> <span>/></span> <span>12</span> <span><!--</span><span> 把主题设置为simple,如name里的内容记不住,请在core包里的default.properties里面找 </span><span>--></span> <span>13</span> <span><span>constant </span><span>name</span><span>="struts.ui.theme"</span><span> value</span><span>="simple"</span> <span>/></span> <span>14</span> <span>15</span> <span><span>package </span><span>name</span><span>="default"</span><span> namespace</span><span>="/"</span><span> extends</span><span>="struts-default"</span><span>></span> <span>16</span> <span>17</span> <span></span><span>package</span><span>></span> <span>18</span> <span>19</span> <span><!--</span><span> Add packages here </span><span>--></span> <span>20</span> <span>21</span> <span></span><span>struts</span><span>></span></span></span></span></span></span></span>
如果xml的代码不提示,在我们下载的项目包里面找,具体位置为:struts-2.3.15.1/src/core/src/main/resources/struts-2.3.dtd。
然后配置到myeclipse里面即可。
用好压工具打开struts2-blank.war,点击WEB-INF,将web.xml里面的以下内容拷贝到我们的web.xml里面:
<span> 1</span> <span><span>filter</span><span>></span> <span> 2</span> <span> 3</span> <span><span>filter-name</span><span>></span>struts2<span></span><span>filter-name</span><span>></span> <span> 4</span> <span> 5</span> <span><span>filter-class</span><span>></span>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter<span></span><span>filter-class</span><span>></span> <span> 6</span> <span> 7</span> <span></span><span>filter</span><span>></span> <span> 8</span> <span> 9</span> <span>10</span> <span>11</span> <span><span>filter-mapping</span><span>></span> <span>12</span> <span>13</span> <span><span>filter-name</span><span>></span>struts2<span></span><span>filter-name</span><span>></span> <span>14</span> <span>15</span> <span><span>url-pattern</span><span>></span>/*<span></span><span>url-pattern</span><span>></span> <span>16</span> <span>17</span> <span></span><span>filter-mapping</span><span>></span></span></span></span></span></span></span>
3.添加hibernate3.6的环境:
添加jar包:
1)添加核心包:hibernate3.jar
2)项目包里lib文件夹下面:required里面全部jar包,jpa文件夹里面全部jar包,optional文件夹里c3p0包。
3)mysql驱动包。
添加配置文件:
1)添加hibernate.cfg.xml,具体模板内容如下(在项目环境添加完成之后再做修改):
<span> 1</span> <span><span>DOCTYPE hibernate-configuration PUBLIC </span><span> 2</span> <span> "-//Hibernate/Hibernate Configuration DTD 3.0//EN" </span><span> 3</span> <span> "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"</span><span>></span> <span> 4</span> <span> 5</span> <span><span>hibernate-configuration</span><span>></span> <span> 6</span> <span><span>session-factory </span><span>name</span><span>="foo"</span><span>></span> <span> 7</span> <span><!--</span><span> 显示sql </span><span>--></span> <span> 8</span> <span><span>property </span><span>name</span><span>="show_sql"</span><span>></span>true<span></span><span>property</span><span>></span> <span> 9</span> <span>10</span> <span><span>property </span><span>name</span><span>="hbm2ddl.auto"</span><span>></span>update<span></span><span>property</span><span>></span> <span>11</span> <span><!--</span><span> mysql方言 </span><span>--></span> <span>12</span> <span><span>property </span><span>name</span><span>="dialect"</span><span>></span>org.hibernate.dialect.MySQL5Dialect<span></span><span>property</span><span>></span> <span>13</span> <span><!--</span><span> 数据库连接信息 </span><span>--></span> <span>14</span> <span><!--</span><span> 数据库驱动 </span><span>--></span> <span>15</span> <span><span>property </span><span>name</span><span>="connection.driver_class"</span><span>></span>com.mysql.jdbc.Driver<span></span><span>property</span><span>></span> <span>16</span> <span><span>property </span><span>name</span><span>="connection.url"</span><span>></span>jdbc:mysql:///oa<span></span><span>property</span><span>></span> <span>17</span> <span><span>property </span><span>name</span><span>="connection.username"</span><span>></span>root<span></span><span>property</span><span>></span> <span>18</span> <span><span>property </span><span>name</span><span>="connection.password"</span><span>></span>root<span></span><span>property</span><span>></span> <span>19</span> <span><!--</span><span> 导入映射文件 </span><span>20</span> <span> <mapping resource="org/hibernate/test/legacy/Simple.hbm.xml"/> </span><span>--></span> <span>21</span> <span></span><span>session-factory</span><span>></span> <span>22</span> <span></span><span>hibernate-configuration</span><span>></span></span></span></span></span></span></span></span></span></span></span>
2)添加XX.hbm.xml模板,内容如下(具体代码开发时添加修改):
<span>1</span> <span></span><span>xml version="1.0"</span><span>?></span> <span>2</span> <span><span>DOCTYPE hibernate-mapping PUBLIC </span><span>3</span> <span> "-//Hibernate/Hibernate Mapping DTD 3.0//EN" </span><span>4</span> <span> "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"</span><span>></span> <span>5</span> <span>6</span> <span><span>hibernate-mapping </span><span>package</span><span>="org.hibernate.test.typedmanytoone"</span><span>></span> <span>7</span> <span>8</span> <span></span><span>hibernate-mapping</span><span>></span></span></span>
4.添加Spring2.5.6开发环境:
添加jar包:
1)核心包:
spring.jar
2)依赖包:
spring2.5.6/lib/aspectj下面所有jar包
spring2.5.6/lib/lib/cglib下面的jar包
spring2.5.6/lib/jakarta-commons/commons-logging.jar(如已经添加就不需要了)
添加配置文件applicationConxt.xml,模板内容如下(具体内容在ssh整合时完善):
<span> 1</span> <span></span><span>xml version="1.0" encoding="UTF-8"</span><span>?></span> <span> 2</span> <span><!--</span> <span> 3</span> <span> - Middle tier application context definition for the image database. </span><span> 4</span> <span>--></span> <span> 5</span> <span><span>beans </span><span>xmlns</span><span>="http://www.springframework.org/schema/beans"</span> <span> 6</span> <span> xmlns:xsi</span><span>="http://www.w3.org/2001/XMLSchema-instance"</span> <span> 7</span> <span> xmlns:context</span><span>="http://www.springframework.org/schema/context"</span> <span> 8</span> <span> xmlns:tx</span><span>="http://www.springframework.org/schema/tx"</span> <span> 9</span> <span> xsi:schemaLocation</span><span>="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd </span><span>10</span> <span> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd </span><span>11</span> <span> http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"</span><span>></span> <span>12</span> <span>13</span> <span><!--</span><span> 自动扫描与装配bean </span><span>--></span> <span>14</span> <span><span>context:component-scan </span><span>base-package</span><span>="cn.clear.oa"</span><span>></span><span>context:component-scan</span><span>></span> <span>15</span> <span>16</span> <span>17</span> <span></span><span>beans</span><span>></span></span></span>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Fermat's last theorem, about to be conquered by AI? And the most meaningful part of the whole thing is that Fermat’s Last Theorem, which AI is about to solve, is precisely to prove that AI is useless. Once upon a time, mathematics belonged to the realm of pure human intelligence; now, this territory is being deciphered and trampled by advanced algorithms. Image Fermat's Last Theorem is a "notorious" puzzle that has puzzled mathematicians for centuries. It was proven in 1993, and now mathematicians have a big plan: to recreate the proof using computers. They hope that any logical errors in this version of the proof can be checked by a computer. Project address: https://github.com/riccardobrasca/flt

Many users are increasingly favoring the electronic ecosystem of Xiaomi smart home interconnection in modern life. After connecting to the Mijia APP, you can easily control the connected devices with your mobile phone. However, many users still don’t know how to add Mijia to their homes. app, then this tutorial guide will bring you the specific connection methods and steps, hoping to help everyone in need. 1. After downloading Mijia APP, create or log in to Xiaomi account. 2. Adding method: After the new device is powered on, bring the phone close to the device and turn on the Xiaomi TV. Under normal circumstances, a connection prompt will pop up. Select "OK" to enter the device connection process. If no prompt pops up, you can also add the device manually. The method is: after entering the smart home APP, click the 1st button on the lower left

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

1. Open the PPT software and enter its main interface. 2. Delete the two input boxes that click here to add a title and subtitle. 3. Click the Insert menu and select the smartart tool. 4. Open the Select SmartArt Graphics dialog box. 5. Click Balance in the Relationship category and press OK. 6. Insert a balance relationship diagram into the PPT. 7. Enter the required text content for the balanced relationship diagram. 8. Choose to add a smartart style. 9. At this point, a balanced relationship diagram has been created in PPT.
