- 浏览: 556797 次
- 性别:
- 来自: 武汉
文章分类
- 全部博客 (533)
- spring (8)
- struts (21)
- hibernate (17)
- java其他 (73)
- 设计模式 (2)
- 开发软件/插件 (26)
- android (8)
- extjs4 (1)
- 网络编程 (4)
- 生活杂记 (3)
- ibatis (5)
- 应用服务器 (4)
- js (26)
- html/css (16)
- linux (0)
- db (32)
- jsp/servlet (13)
- xml (9)
- webservice (10)
- 错误/异常处理 (23)
- 线程 (10)
- maven (7)
- lucene (2)
- python (0)
- 报表 (1)
- mongodb (6)
- restful (6)
- ssl (1)
最新评论
-
zmwxiaoming:
...
struts2拦截器验证登陆状态 -
u012413283:
感谢楼主,同样的问题解决了
eclipse下安装m2e的maven插件报错的各类解决方案(含pom editor没装好的解决方案) -
javalucky:
你妹,想不吐槽都不行啊,eclipse 那来的maven4My ...
clipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin: -
zhaoyh82:
感谢楼主
eclipse下安装m2e的maven插件报错的各类解决方案(含pom editor没装好的解决方案) -
hua2011:
按照楼主说的,还是没有出现pom editor编辑器,麻烦楼主 ...
eclipse下安装m2e的maven插件报错的各类解决方案(含pom editor没装好的解决方案)
struts2官方入门案列curd 编辑
偶然在查看文档时,看到这个demo,后来认真看了下真是麻雀虽小,很单一的struts2的增删改查,但是却从各方面诠释着struts2这一开源框架的精妙设计和丰富的可定制性。文档上提供是片段式的代码讲解,且是英文的,所以这里记录一下,方面以后查看。
和以前一样,先上效果图:
图一:
图二:
图三:
图四:
虽然从图上看的话,以上功能简单,但是代码里,时刻体现着该框架的设计之优秀,首先,我们新建一个web功能CusManager,并加入struts2的7个必要jar包。
第一步,新建两个实体类Department和Employee作POJO,代码如下:
Java代码
- packagecom.aurifa.struts2.tutorial.model;
- importjava.io.Serializable;
- publicclassDepartmentimplementsSerializable{
- IntegerdepartmentId;
- Stringname;
- publicDepartment(){
- }
- publicDepartment(IntegerdepartmentId,Stringname){
- this.departmentId=departmentId;
- this.name=name;
- }
- publicIntegergetDepartmentId(){
- returndepartmentId;
- }
- publicvoidsetDepartmentId(IntegerdepartmentId){
- this.departmentId=departmentId;
- }
- publicStringgetName(){
- returnname;
- }
- publicvoidsetName(Stringname){
- this.name=name;
- }
- }
Java代码
- packagecom.aurifa.struts2.tutorial.model;
- importjava.io.Serializable;
- publicclassEmployeeimplementsSerializable{
- privateIntegeremployeeId;
- privateIntegerage;
- privateStringfirstName;
- privateStringlastName;
- privateDepartmentdepartment;
- publicEmployee(){
- }
- publicEmployee(IntegeremployeeId,StringfirstName,StringlastName,
- Integerage,Departmentdepartment){
- this.employeeId=employeeId;
- this.firstName=firstName;
- this.lastName=lastName;
- this.age=age;
- this.department=department;
- }
- publicDepartmentgetDepartment(){
- returndepartment;
- }
- publicvoidsetDepartment(Departmentdepartment){
- this.department=department;
- }
- publicIntegergetEmployeeId(){
- returnemployeeId;
- }
- publicvoidsetEmployeeId(IntegeremployeeId){
- this.employeeId=employeeId;
- }
- publicIntegergetAge(){
- returnage;
- }
- publicvoidsetAge(Integerage){
- this.age=age;
- }
- publicStringgetFirstName(){
- returnfirstName;
- }
- publicvoidsetFirstName(StringfirstName){
- this.firstName=firstName;
- }
- publicStringgetLastName(){
- returnlastName;
- }
- publicvoidsetLastName(StringlastName){
- this.lastName=lastName;
- }
- }
第二步,定义dao层的接口,代码如下:
Java代码
- packagecom.aurifa.struts2.tutorial.dao;
- importjava.util.List;
- importjava.util.Map;
- publicinterfaceDepartmentDao{
- publicListgetAllDepartments();
- publicMapgetDepartmentsMap();
- }
Java代码
- packagecom.aurifa.struts2.tutorial.dao;
- importjava.util.List;
- importcom.aurifa.struts2.tutorial.model.Employee;
- publicinterfaceEmployeeDao{
- publicListgetAllEmployees();
- publicEmployeegetEmployee(Integerid);
- publicvoidupdate(Employeeemp);
- publicvoidinsert(Employeeemp);
- publicvoiddelete(Integerid);
- }
第三步,完成上述接口的实现类,代码如下:
Java代码
- packagecom.aurifa.struts2.tutorial.dao;
- importjava.util.*;
- importcom.aurifa.struts2.tutorial.model.Department;
- publicclassDepartmentNoDBdaoimplementsDepartmentDao{
- privatestaticListdepartments;
- privatestaticMapdepartmentsMap;
- static{
- departments=newArrayList();
- departments.add(newDepartment(newInteger(100),"Accounting"));
- departments.add(newDepartment(newInteger(200),"R&D"));
- departments.add(newDepartment(newInteger(300),"Sales"));
- departmentsMap=newHashMap();
- Iteratoriter=departments.iterator();
- while(iter.hasNext()){
- Departmentdept=(Department)iter.next();
- departmentsMap.put(dept.getDepartmentId(),dept);
- }
- }
- publicListgetAllDepartments(){
- returndepartments;
- }
- publicMapgetDepartmentsMap(){
- returndepartmentsMap;
- }
- }
Java代码
- packagecom.aurifa.struts2.tutorial.dao;
- importjava.util.ArrayList;
- importjava.util.Iterator;
- importjava.util.List;
- importjava.util.Map;
- importorg.apache.commons.logging.Log;
- importorg.apache.commons.logging.LogFactory;
- importcom.aurifa.struts2.tutorial.model.Department;
- importcom.aurifa.struts2.tutorial.model.Employee;
- publicclassEmployeeNoDBdaoimplementsEmployeeDao{
- privatestaticMapdepartmentsMap;
- privatestaticArrayListemployees;
- static{
- employees=newArrayList();
- employees.add(newEmployee(newInteger(1),"John","Doe",newInteger(36),newDepartment(newInteger(100),"Accounting")));
- employees.add(newEmployee(newInteger(2),"Bob","Smith",newInteger(25),newDepartment(newInteger(300),"Sales")));
- DepartmentDaodeptDao=newDepartmentNoDBdao();
- departmentsMap=deptDao.getDepartmentsMap();
- }
- Loglogger=LogFactory.getLog(this.getClass());
- publicListgetAllEmployees(){
- returnemployees;
- }
- publicEmployeegetEmployee(Integerid){
- Employeeemp=null;
- Iteratoriter=employees.iterator();
- while(iter.hasNext()){
- emp=(Employee)iter.next();
- if(emp.getEmployeeId().equals(id)){
- break;
- }
- }
- returnemp;
- }
- publicvoidupdate(Employeeemp){
- Integerid=emp.getEmployeeId();
- for(inti=0;i<employees.size();i++){
- EmployeetempEmp=(Employee)employees.get(i);
- if(tempEmp.getEmployeeId().equals(id)){
- emp.setDepartment((Department)departmentsMap.get(emp.getDepartment().getDepartmentId()));
- employees.set(i,emp);
- break;
- }
- }
- }
- publicvoidinsert(Employeeemp){
- intlastId=0;
- Iteratoriter=employees.iterator();
- while(iter.hasNext()){
- Employeetemp=(Employee)iter.next();
- if(temp.getEmployeeId().intValue()>lastId){
- lastId=temp.getEmployeeId().intValue();
- }
- }
- emp.setDepartment((Department)departmentsMap.get(emp.getDepartment().getDepartmentId()));
- emp.setEmployeeId(newInteger(lastId+1));
- employees.add(emp);
- }
- publicvoiddelete(Integerid){
- for(inti=0;i<employees.size();i++){
- EmployeetempEmp=(Employee)employees.get(i);
- if(tempEmp.getEmployeeId().equals(id)){
- employees.remove(i);
- break;
- }
- }
- }
- }
第四步,根据dao层,完成service层(因为代码较为简单,未明确分包),代码如下:
Java代码
- packagecom.aurifa.struts2.tutorial.service;
- importjava.util.List;
- importcom.aurifa.struts2.tutorial.dao.DepartmentDao;
- importcom.aurifa.struts2.tutorial.dao.DepartmentNoDBdao;
- publicclassDepartmentDaoServiceimplementsDepartmentService{
- privateDepartmentDaodao;
- publicDepartmentDaoService(){
- this.dao=newDepartmentNoDBdao();
- }
- publicListgetAllDepartments(){
- returndao.getAllDepartments();
- }
- }
Java代码
- packagecom.aurifa.struts2.tutorial.service;
- importjava.util.List;
- importcom.aurifa.struts2.tutorial.dao.EmployeeDao;
- importcom.aurifa.struts2.tutorial.dao.EmployeeNoDBdao;
- importcom.aurifa.struts2.tutorial.model.Employee;
- publicclassEmployeeDaoServiceimplementsEmployeeService{
- privateEmployeeDaodao;
- publicEmployeeDaoService(){
- this.dao=newEmployeeNoDBdao();
- }
- publicListgetAllEmployees(){
- returndao.getAllEmployees();
- }
- publicvoidupdateEmployee(Employeeemp){
- dao.update(emp);
- }
- publicvoiddeleteEmployee(Integerid){
- dao.delete(id);
- }
- publicEmployeegetEmployee(Integerid){
- returndao.getEmployee(id);
- }
- publicvoidinsertEmployee(Employeeemp){
- dao.insert(emp);
- }
- }
第五步,service层的接口,代码如下:
Java代码
- packagecom.aurifa.struts2.tutorial.service;
- importjava.util.List;
- publicinterfaceDepartmentService{
- publicListgetAllDepartments();
- }
Java代码
- packagecom.aurifa.struts2.tutorial.service;
- importjava.util.List;
- importcom.aurifa.struts2.tutorial.model.Employee;
- publicinterfaceEmployeeService{
- publicListgetAllEmployees();
- publicvoidupdateEmployee(Employeeemp);
- publicvoiddeleteEmployee(Integerid);
- publicEmployeegetEmployee(Integerid);
- publicvoidinsertEmployee(Employeeemp);
- }
第六步,则是action层,代码如下:
Java代码
- packagecom.aurifa.struts2.tutorial.action;
- importjava.util.List;
- importorg.apache.commons.logging.Log;
- importorg.apache.commons.logging.LogFactory;
- importcom.aurifa.struts2.tutorial.model.Employee;
- importcom.aurifa.struts2.tutorial.service.DepartmentDaoService;
- importcom.aurifa.struts2.tutorial.service.DepartmentService;
- importcom.aurifa.struts2.tutorial.service.EmployeeDaoService;
- importcom.aurifa.struts2.tutorial.service.EmployeeService;
- importcom.opensymphony.xwork2.ActionSupport;
- importcom.opensymphony.xwork2.Preparable;
- publicclassEmployeeActionextendsActionSupportimplementsPreparable{
- /**
- *
- */
- privatestaticfinallongserialVersionUID=-6886717038958304064L;
- privateLoglogger=LogFactory.getLog(this.getClass());
- privatestaticEmployeeServiceempService=newEmployeeDaoService();
- privatestaticDepartmentServicedeptService=newDepartmentDaoService();
- privateEmployeeemployee;
- privateListemployees;
- privateListdepartments;
- publicvoidprepare()throwsException{
- departments=deptService.getAllDepartments();
- if(employee!=null&&employee.getEmployeeId()!=null){
- employee=empService.getEmployee(employee.getEmployeeId());
- }
- }
- publicStringdoSave(){
- if(employee.getEmployeeId()==null){
- empService.insertEmployee(employee);
- }else{
- empService.updateEmployee(employee);
- }
- returnSUCCESS;
- }
- publicStringdoDelete(){
- empService.deleteEmployee(employee.getEmployeeId());
- returnSUCCESS;
- }
- publicStringdoList(){
- employees=empService.getAllEmployees();
- returnSUCCESS;
- }
- publicStringdoInput(){
- returnINPUT;
- }
- /**
- *@returnReturnstheemployee.
- */
- publicEmployeegetEmployee(){
- returnemployee;
- }
- /**
- *@paramemployee
- *Theemployeetoset.
- */
- publicvoidsetEmployee(Employeeemployee){
- this.employee=employee;
- }
- /**
- *@returnReturnstheemployees.
- */
- publicListgetEmployees(){
- returnemployees;
- }
- /**
- *@returnReturnsthedepartments.
- */
- publicListgetDepartments(){
- returndepartments;
- }
- }
接着在同级目录下,我们添加该action的同名验证框架,代码如下:
Employeeaction-crud-validation.xml代码
- <!DOCTYPEvalidatorsPUBLIC"-//OpenSymphonyGroup//XWorkValidator1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
- <validators>
- <fieldname="employee.firstName">
- <field-validatortype="requiredstring">
- <messagekey="errors.required.firstname"/>
- </field-validator>
- </field>
- <fieldname="employee.lastName">
- <field-validatortype="requiredstring">
- <messagekey="errors.required.lastname"/>
- </field-validator>
- </field>
- <fieldname="employee.age">
- <field-validatortype="required"short-circuit="true">
- <messagekey="errors.required.age"/>
- </field-validator>
- <field-validatortype="int">
- <paramname="min">18</param>
- <paramname="max">65</param>
- <messagekey="errors.required.age.limit"/>
- </field-validator>
- </field>
- </validators>
至此,代码部分大抵完成,下面在src下,新建所需的配置文件:
首先是log4j,代码如下:
Xml代码
- <?xmlversion="1.0"encoding="UTF-8"?>
- <!DOCTYPElog4j:configurationSYSTEM"log4j.dtd">
- <log4j:configurationxmlns:log4j="http://jakarta.apache.org/log4j/">
- <appendername="stdout"class="org.apache.log4j.ConsoleAppender">
- <layoutclass="org.apache.log4j.TTCCLayout"/>
- </appender>
- <!--logdetailconfiguration-->
- <loggername="com.opensymphony.xwork">
- <levelvalue="error"/>
- <appender-refref="stdout"/>
- </logger>
- <loggername="com.opensymphony.webwork">
- <levelvalue="error"/>
- <appender-refref="stdout"/>
- </logger>
- <loggername="freemarker">
- <levelvalue="warn"/>
- <appender-refref="stdout"/>
- </logger>
- <loggername="com.mevipro">
- <levelvalue="debug"/>
- <appender-refref="stdout"/>
- </logger>
- <root>
- <levelvalue="error"/>
- <appender-refref="stdout"/>
- </root>
- </log4j:configuration>
其次是struts.xml,代码如下:
Xml代码
- <!DOCTYPEstrutsPUBLIC
- "-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <!--Includewebworkdefault(fromtheStrutsJAR).-->
- <includefile="struts-default.xml"/>
- <!--Configurationforthedefaultpackage.-->
- <packagename="default"extends="struts-default">
- <!--Defaultinterceptorstack.-->
- <default-interceptor-refname="paramsPrepareParamsStack"/>
- <actionname="index"class="com.aurifa.struts2.tutorial.action.EmployeeAction"method="list">
- <resultname="success">/jsp/employees.jsp</result>
- <!--wedon'tneedthefullstackhere-->
- <interceptor-refname="basicStack"/>
- </action>
- <actionname="crud"class="com.aurifa.struts2.tutorial.action.EmployeeAction"method="input">
- <resultname="success"type="redirect-action">index</result>
- <resultname="input">/jsp/employeeForm.jsp</result>
- <resultname="error">/jsp/error.jsp</result>
- </action>
- </package>
- </struts>
然后是struts的国际化文件,struts.properties和guest.properties,代码分别如下:
Struts.properties代码
- struts.custom.i18n.resources=guest
Guest.properties代码
- #labels
- application.title=EmployeeMaintenanceApplication
- label.employees=Employees
- label.delete=Delete
- label.edit=Edit
- label.employee.edit=EditEmployee
- label.employee.add=AddEmployee
- label.firstName=FirstName
- label.lastName=LastName
- label.department=Department
- label.age=Age
- #buttonlabels
- button.label.submit=Submit
- button.label.cancel=Cancel
- ##--errors
- errors.prefix=<spanstyle="color:red;font-weight:bold;">
- errors.suffix=</span>
- errors.general=AnErrorHasOcccured
- errors.required.firstname=Nameisrequired.
- errors.required.lastname=Lastnameisrequired.
- errors.required.age=Pleaseprovideanage.
- errors.required.age.limit=Pleaseprovideanagebetween${min}and${max}.
- errors.required.department=Departmentisrequired.
最后贴上运行时的jsp页面,代码不多,下面我分别贴出来,代码如下:
Index.jsp代码
- <%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>
- <%
- Stringpath=request.getContextPath();
- StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
- <html>
- <head>
- <basehref="<%=basePath%>">
- <title>MyJSP'index.jsp'startingpage</title>
- <metahttp-equiv="pragma"content="no-cache">
- <metahttp-equiv="cache-control"content="no-cache">
- <metahttp-equiv="expires"content="0">
- <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
- <metahttp-equiv="Refresh"content="0;URL=index.action">
- <!--
- <linkrel="stylesheet"type="text/css"href="styles.css">
- -->
- </head>
- <body>
- ThisismyJSPpage.<br>
- </body>
- </html>
Employeeform.jsp代码
- <%@pagecontentType="text/html;charset=UTF-8"language="java"%>
- <%@taglibprefix="s"uri="/struts-tags"%>
- <s:iftest="employee==null||employee.employeeId==null">
- <s:setname="title"value="%{'Addnewemployee'}"/>
- </s:if>
- <s:else>
- <s:setname="title"value="%{'Updateemployee'}"/>
- </s:else>
- <html>
- <head>
- <linkhref="css/main.css"rel="stylesheet"type="text/css"/>
- <style>td{white-space:nowrap;}</style>
- <title><s:propertyvalue="#title"/></title>
- </head>
- <body>
- <divclass="titleDiv"><s:textname="application.title"/></div>
- <h1><s:propertyvalue="#title"/></h1>
- <%--<s:actionerror/>--%>
- <%--<s:actionmessage/>--%>
- <s:formaction="crud!save.action"method="post">
- <s:textfieldname="employee.firstName"value="%{employee.firstName}"label="%{getText('label.firstName')}"size="40"/>
- <s:textfieldname="employee.lastName"value="%{employee.lastName}"label="%{getText('label.lastName')}"size="40"/>
- <s:textfieldname="employee.age"value="%{employee.age}"label="%{getText('label.age')}"size="20"/>
- <s:selectname="employee.department.departmentId"value="%{employee.department.departmentId}"list="departments"listKey="departmentId"listValue="name"/>
- <%--<s:selectname="gender"list="%{#{'male':'Male','female':'Female'}}"/>--%>
- <s:hiddenname="employee.employeeId"value="%{employee.employeeId}"/>
- <s:submitvalue="%{getText('button.label.submit')}"/>
- <s:submitvalue="%{getText('button.label.cancel')}"name="redirect-action:index"/>
- </s:form>
- </body>
- </html>
Employees.jsp代码
- <%@pagecontentType="text/html;charset=UTF-8"language="java"%>
- <%@taglibprefix="s"uri="/struts-tags"%>
- <html>
- <head>
- <linkhref="css/main.css"rel="stylesheet"type="text/css"/>
- <title><s:textname="label.employees"/></title>
- </head>
- <body>
- <divclass="titleDiv"><s:textname="application.title"/></div>
- <h1><s:textname="label.employees"/></h1>
- <s:urlid="url"action="crud!input"/>
- <ahref="<s:propertyvalue="#url"/>">AddNewEmployee</a>
- <br/><br/>
- <tableclass="borderAll">
- <tr>
- <th><s:textname="label.firstName"/></th>
- <th><s:textname="label.lastName"/></th>
- <th><s:textname="label.age"/></th>
- <th><s:textname="label.department"/></th>
- <th> </th>
- </tr>
- <s:iteratorvalue="employees"status="status">
- <trclass="<s:iftest="#status.even">even</s:if><s:else>odd</s:else>">
- <tdclass="nowrap"><s:propertyvalue="firstName"/></td>
- <tdclass="nowrap"><s:propertyvalue="lastName"/></td>
- <tdclass="nowrap"><s:propertyvalue="age"/></td>
- <tdclass="nowrap"><s:propertyvalue="department.name"/></td>
- <tdclass="nowrap">
- <s:urlaction="crud!input"id="url">
- <s:paramname="employee.employeeId"value="employeeId"/>
- </s:url>
- <ahref="<s:propertyvalue="#url"/>">Edit</a>
-
- <s:urlaction="crud!delete"id="url">
- <s:paramname="employee.employeeId"value="employeeId"/>
- </s:url>
- <ahref="<s:propertyvalue="#url"/>">Delete</a>
- </td>
- </tr>
- </s:iterator>
- </table>
- </body>
- </html>
Error.jsp代码
- <%@pagecontentType="text/html;charset=UTF-8"language="java"%>
- <%@taglibprefix="s"uri="/struts-tags"%>
- <html>
- <head>
- <title>ErrorPage</title>
- <linkhref="<s:urlvalue='/css/main.css'/>"rel="stylesheet"type="text/css"/>
- </head>
- <body>
- <s:actionerror/>
- <br/>
- Inorderthatthedevelopmentteamcanaddressthiserror,pleasereportwhatyouweredoingthatcausedthiserror.
- <br/><br/>
- Thefollowinginformationcanhelpthedevelopment
- teamfindwheretheerrorhappenedandwhatcanbedonetopreventitfrom
- happeninginthefuture.
- </body>
- </html>
以上页面引用到的css文件,代码如下:
Main.css代码
- html,body{
- margin-left:10px;
- margin-right:10px;
- margin-bottom:5px;
- color:black;
- background-color:white;
- font-family:Verdana,Arial,sans-serif;
- font-size:12px;
- }
- .titleDiv{
- background-color:#EFFBEF;
- font-weight:bold;
- font-size:18px;
- text-align:left;
- padding-left:10px;
- padding-top:10px;
- padding-bottom:10px;
- border:2pxsolid#8F99EF;
- }
- h1{font-weight:bold;color:brown;font-size:15px;text-align:left;}
- td{font-size:12px;padding-right:10px;}
- th{text-align:left;font-weight:bold;font-size:13px;padding-right:10px;}
- .tdLabel{font-weight:bold;white-space:nowrap;vertical-align:top;}
- A{color:#4A825A;text-decoration:none;}
- A:link{text-decoration:none;}
- A:visited{text-decoration:none;}
- A:hover{text-decoration:none;color:red;}
- .borderAll{
- border:2pxsolid#8F99EF;
- }
- .butStnd{
- font-family:arial,sans-serif;
- font-size:11px;
- width:105px;
- background-color:#DCDFFA;color:#4A825A;font-weight:bold;
- }
- .error{
- color:red;
- font-weight:bold;
- }
- .errorSection{
- padding-left:18px;
- padding-top:2px;
- padding-bottom:10px;
- padding-right:5px;
- }
- .even{background-color:#EFFBEF;}
- .odd{background-color:white;}
- .nowrap{white-space:nowrap;}
到这里,这个例子基本上就完成了,其主要亮点在action层的实现类和验证xml,而jsp页面的tag和struts.xml也比较耐看,将web.xml配置好struts2的监听以后,部署到tomcat之后,浏览器键入:localhost:8080/CusManager,即可得到以上效果图所示。
代码我是全部都贴上了,连css也有,不会有任何地方的缺失,假使大家运行报错,请认真查看错误,并检查自己的web.xml的配置,除此之外不会有任何错误。
相关推荐
这个官方入门案例“struts2官方入门案列curd”着重于介绍如何使用Struts2实现CRUD(创建、读取、更新、删除)操作,这是任何Web应用中最基本的功能需求。下面我们将详细探讨Struts2框架以及如何通过它实现CRUD操作。...
总的来说,"Struts2-Sqlite3-CURD"项目展示了如何利用Struts2框架的灵活性和SQLite3的便捷性,构建一个功能完备的Web应用程序,用于管理和操作数据库。这对于学习Java web开发和SQLite数据库操作的初学者是一个很好...
Struts2、Hibernate和Spring是Java Web开发中的三大框架,它们各自负责应用程序的不同层面:Struts2处理MVC(Model-View-Controller)架构中的控制层,Hibernate专注于数据持久化,而Spring则提供了全面的依赖注入...
在Java Web开发中,"Struts2+Spring+IBatis"是一个常见的企业级应用框架组合,也被称为SSI(Struts2、Spring、iBatis)框架。这种组合提供了模型-视图-控制器(MVC)架构,事务管理,以及灵活的数据访问机制。以下是...
Struts2和Hibernate是两种非常流行的Java开源框架,它们分别用于MVC(Model-View-Controller)架构的控制层和持久层的管理。Struts2提供了强大的动作调度和页面渲染能力,而Hibernate则是面向对象的数据库映射工具,...
Struts2和Hibernate是两种非常重要的Java开源框架,它们在Web开发中被广泛使用。Struts2是一个MVC(Model-View-Controller)框架,它主要用于处理用户请求和控制应用程序流程,而Hibernate则是一个对象关系映射(ORM...
"struts2DeptCURD"这个项目很可能是关于在Struts2框架下实现部门管理的CRUD(Create, Read, Update, Delete)操作。下面我们将深入探讨Struts2框架及其在CRUD操作中的应用。 首先,Struts2作为MVC框架的核心组件,...
Struts2+Mysql实现CURD,stuts2中使用servlet中Request,session,context对象
Struts2和Hibernate是两种非常重要的Java Web开发框架,它们在构建新闻发布系统中起到了关键作用。Struts2作为MVC(Model-View-Controller)架构的一部分,主要负责控制应用程序的流程,而Hibernate则是一个对象关系...
在这个名为"Struts、Hibernate、Spring实现CURD所用Jar包(Lib1)"的压缩包中,包含的是用于实现数据库CRUD操作(创建Create、读取Read、更新Update、删除Delete)所需的基础库文件。 Struts是Apache组织开发的一个...
2.数据库操作使用c3p0连接池和dbtuils组件,对表的CURD,二者搭配感觉很easy,没有使用hibernate。 3.控制器采用action开发,替代传统的servlet,直接跳转页面返回一个字符串即可,需配置struts.xml对应的jsp。 4....
Struts2、Spring、iBatis 和 Oracle 是四个...综上所述,"struts2+spring+ibaites+oracle+CURD" 这个组合提供了完整的 Java Web 应用解决方案,涵盖了从用户交互到数据库操作的整个流程,是企业级开发中常见的技术栈。
Struts2 CRUD是一个基于Apache Struts 2框架的通用数据操作模块,主要用于简化Web应用中的创建、读取、更新和删除(CRUD)操作。这个模块可以帮助开发者快速构建数据管理功能,减少重复代码,提高开发效率。Struts2...
Struts2_02CURD : 关于Struts2的增、删、改和查 实际业务中数据来自数据库,从DAO层查询,本实例使用静态资源的方式模拟, 主要是关于CURD的操作方式。 Struts2_03Taglib : Struts2常用标签的使用方法 Struts2...
这个压缩包文件“Struts2.CURD”很可能包含了实现上述功能的源代码,包括Action类、DAO接口及实现、配置文件和视图文件。开发者可以通过查看这些文件,学习如何结合Struts2和Oracle实现基本的数据操作功能。
JFinal入门CURD实现对数据库基本的增删改查,EclipseEE+Mysql+Tomcat7 在主页面可以增加用户,删除用户,修改用户. 1.解压后将jfinallearn1.sql的数据弄到自己的mysql里(只有一张user表) 2.修改jfinalLearn1\src...
在本示例中,我们将深入探讨如何在Spring Boot框架中整合Spring、Struts2和MyBatis(SSM)来实现完整的数据CURD操作。Spring Boot以其简洁的配置和快速的开发能力,使得构建Web应用变得更加高效。接下来,我们将详细...