短学期第二篇随笔

这三天明显感觉有节奏了,老师采取了先拉进度,然后纠错,这样可以给我们一个方向,明确当天的任务。很好的解决了做的快的同学被挂起,只能等老师先帮同学调试,有时候会调试到很晚,快下课才发布新任务,导致大家一起加班。

这几天做了直接查询功能,代码如下:

CustomerListAction:

package com.crm.action;

import java.util.Map;

import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerListAction extends ActionSupport{
 private CustomerService service;
 public void setService(CustomerService service){
  this.service = service;
 }
 
 @Override
 public String execute() throws Exception{
  Map map = (Map)ActionContext.getContext().get("request");
  map.put("list",this.service.findAllCustomer());
  return SUCCESS;
 }
}

CustomerDao中新增的直接查询代码:

CustomerDaoImpl中新增的直接查询代码:

CustomerService中新增的直接查询代码:

CustomerServiceImpl中新增的直接查询代码:

applicationContext中新增的直接查询代码:

在http://127.0.0.1:8080/sshtest/jsp/customerInfo.jsp页面中会将所有信息直接列出。

接下来还做了条件查询和删除操作:

1.条件查询:

新增代码:

新建了CustomerFindByCdAction,代码如下:

点击查询才列出信息,如果无输入,直接点击查询,就会列出所有信息,如图:

点击前:

点击后:

2.删除功能:

新增的代码:

CustomerDao中:

/**
  * 删除客户信息
  * @param customer
  */
 public void deleteCustomer(Customer customer);

CustomerDaoImpl中:

public void deleteCustomer(Customer customer) {
  // TODO Auto-generated method stub
  this.getHibernateTemplate().delete(customer);
 }

CustomerService中:

/**
  * 删除客户信息
  * @param cust
  */
 public void deleteCustomer(Customer customer);

CustomerServiceImpl中:

public void deleteCustomer(Customer customer) {
  // TODO Auto-generated method stub
  this.customerdao.deleteCustomer(customer);
 }

strurs中:

<!-- 删除 -->
  <action name="deleteCustomer" class="customerRemoveAction">
   <result>/jsp/customerInfo.jsp</result>
  </action>

applicationContext.xml中:

<!--配置-删除deleteAction  -->
 <bean id="customerRemoveAction" class="com.crm.action.CustomerRemoveAction">
  <property name="removeService" ref="CustomerService"></property>
 </bean>

新建了一个CustomerRemoveAction类:

package com.crm.action;

import com.crm.bean.Customer;
import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerRemoveAction extends ActionSupport {
 private Customer customer;
 private CustomerService removeService;
 
 public void setService(CustomerService removeService) {
  this.removeService = removeService;
 }

public CustomerService getRemoveService() {
  return getRemoveService();
 }
 
 public void setRemoveService(CustomerService removeService) {
  this.removeService = removeService;
 }

public Customer getCustomer() {
  return customer;
 }

public void setCustomer(Customer customer) {
  this.customer = customer;
 }

@Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  this.removeService.deleteCustomer(customer);
  return SUCCESS;
 }

}

点击删除,就会删掉该条信息效果如下:

最后还添加了修改操作以及下拉菜单功能:

添加的代码和条件查询功能、删除功能相似,主要列举新建的CustomerUpdateAction、CustomerUpdatePreviewAction、TypeAction和Type类

1.代码:

CustomerUpdatePreviewAction:

package com.crm.action;

import com.crm.bean.Customer;
import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerUpdatePreviewAction extends ActionSupport{
 private CustomerService  updatePvService;
 private Customer customer;
 
 public CustomerService getUpdatePvService() {
  return updatePvService;
 }
 
 public void setUpdatePvService(CustomerService updatePvService) {
  this.updatePvService = updatePvService;
 }
 
 public Customer getCustomer() {
  return customer;
 }
 
 public void setCustomer(Customer customer) {
  this.customer = customer;
 }
 
 @Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  customer = this.updatePvService.findCustomerById(customer.getID());
  return SUCCESS;
 }
}

CustomerUpdateAction:

package com.crm.action;

import java.util.ArrayList;
import java.util.List;

import com.crm.bean.Customer;
import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerUpdateAction extends ActionSupport{
 private CustomerService updateService;
 private Customer customer;
 List strList = new ArrayList();
 
 public List getStrList() {
  return strList;
 }

public void setStrList(List strList) {
  this.strList = strList;
 }

public CustomerService getUpdateService() {
  return updateService;
 }
 
 public void setUpdateService(CustomerService updateService) {
  this.updateService = updateService;
 }
 
 public Customer getCustomer() {
  return customer;
 }
 
 public void setCustomer(Customer customer) {
  this.customer = customer;
 }
 
 
 
 @Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  this.customer.setCussex(this.strList.get(0).toString());
  this.updateService.updateCustomer(customer);
  return SUCCESS;
 }
}

TypeAction:

package com.crm.action;

import java.util.ArrayList;
import java.util.List;

import com.crm.bean.Type;
import com.opensymphony.xwork2.ActionSupport;

public class TypeAction extends ActionSupport {
 private List<Type> strList = new ArrayList<Type>();

public List<Type> getStrList() {
  List<Type> list = new ArrayList<Type>();
  Type type1 = new Type();
  type1.setID("1");
  type1.setName("男");
  
  Type type2 = new Type();
  type2.setID("2");
  type2.setName("女");
  
  Type type3 = new Type();
  type3.setID("3");
  type3.setName("其他");
  
  list.add(type1);
  list.add(type2);
  list.add(type3);
  this.strList = list;
  return strList;
 }

public void setStrList(List<Type> strList) {
  this.strList = strList;
 }

@Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  return SUCCESS;
 }

}

Type:

package com.crm.bean;

public class Type {

private String ID;//下拉框值
 private String name;//下拉框名称

public String getID() {
  return ID;
 }

public void setID(String ID) {
  this.ID = ID;
 }

public String getName() {
  return name;
 }

public void setName(String name) {
  this.name = name;
 }

}

点击“修改”可修改该条信息,如图:

修改前:

修改中:

点击”性别“的下拉菜单可选择:

修改后:

我基本没有遇到错误,遇到的都是些匹配错误,自己找找就调试好了,所以就不列举了。

这周的任务就结束了,下周要分组做项目,还要继续努力。

时间: 2024-08-04 16:31:00

短学期第二篇随笔的相关文章

短学期第二次随笔

当时做这一段代码的时候运行总是有错误,一直没找到,之后才发现是下面一段代码的大小写没有区分,导致最终一直没有办法成功运行.

深夜睡不着,第二篇随笔,说说js的创建实例化过程

媳妇白天加班太累了,我呢,白天睡太多了,晚上太过于亢奋,自己一个人偷偷的拿着笔记本到客厅写博客~ 上一篇可能很多人看到了觉得就是个joke,那个真的是一个joke,但是在实际开发过程中,很多年轻的coder对于写不写分号很不以为然,要知道,真实生产环境下的代码要远比我栗子中给的代码要复杂得多,因此很有可能不用我的误导,你就看不出来,因此浪费了一下午的宝贵开发时间,所以写代码还是要规范一些. 第二篇文章我依旧不想讲太过于深入的技术,还是说两个“花边新闻”,聊以自慰罢了,看官有兴致你就看,没兴致也可

软件工程短学期实践第一次随笔

在所有科目期末考试之后,我们开始了我们为期两周的短学期软件工程实践,在软件工程实践课上,老师悉心教导我们.第一天老师帮助我们下载java软件.Navicat Premium等软件,还帮助我们配置了java环境,使我们每一个同学可以在自己的电脑上编写以及运行java程序.随后我们跟着老师一起学习一起实践,开始编写主要代码,设计界面. 首先我们用Navicat Premium建立了一个数据库Cust: 有id,custno,custname,telephone,sex等属性 然后,我们开始用Myec

短学期第二次心得

短学期的培训课即将要结束了,下周面临的即将是自己实践写代码.在这几天我们又学习了一些新的知识.我们学习了Javaservlet和springmvc.获取页面中输入的信息 request.getParameter("username") username 是对应的网页中input框的 name.WEB-INF文件下的页面不能直接访问,只能通过转发的方式访问 .把输入的用户名,在下一个页面显示,那就需要传值,可以在下一个页面通过EL 表达式  ${uname} 获取.session.sel

短学期第二次博客

配置好环境后就要开始编写程序了,我们要做的是一个信息录入系统,可以把个人信息录入到连接的数据库中,并能对其进行增删改查等操作. 配置文件 <!-- 配置SaveAction -->  <bean id="custSaveAction" class="com.crm.action.CustSaveAction">  <property name="service">  <ref bean="cus

小学期——第二篇

这三天我们依次制作了新增.查询.修改和删除四大功能. 新增:首先需要设想当我们点此按钮时,应新开一个窗口,以供我们填写新增信息.所以,我们首先要创建一个CustSaveAction类. 代码: 1 package com.crm.action; 2 3 import com.crm.bean.Cust; 4 import com.crm.service.CustService; 5 import com.opensymphony.xwork2.ActionSupport; 6 7 public

短学期实训——第一篇

短学期的第一天,东软的李老师让我们安装两个环境,在安装过程当中,虽然遇到很多的小困难,老师还是 耐心的为我们每位同学解决困难. , 终于在下午我们完成了第一项任务 在第二天我们 开始编写程序 虽然在运行过程中我们每个人的编辑环境都出现了问题,但是在老师的耐心指导下我们终于将此环境运行成功 利用这三天的时间,我深刻体会到了用户的体验,我们所编写的软件是针对用户而言的,我们应当 考虑到用户体验的各种角度,首先就是用户的第一印象,在这里我们要考虑以下两点,第一点就是谁会是我们的目标用户,第二点就是用户

软件工程短学期实践第三次随笔

软件工程短学期实践即将接近尾声,我们的软件工程项目也已趋于完成. 软件工程短学期实践项目: 这是一个简单的客户信息管理维护软件,它能把客户编号.客户姓名.客户电话和客户性别保存在数据库之中,我们可以在数据库中查询保存的客户信息,还可以随时修改以及删除客户信息. 随后,我们在老师的指导下,开始自己修改设计软件,我做的是库存管理项目,代码如下: package com.crm.action; import java.util.Map; import com.crm.bean.Item; import

拿出来分享了!VIP珍藏!!!全网最齐全的 DEDECMS模板 网盘地址!没有你找不到的!【第二篇】

拿出来分享了!VIP珍藏!!!全网最齐全的 DEDECMS模板 网盘地址!没有你找不到的! 模板类型最齐全: -------------优美的走起!---------- 五:DEDECMS模板--服装类模板列表: 织梦模板爱搭配服装行业dedecms门户模板下载.zip 35.25 MB昨天16:43VIP永久 服装行业dedecms模板.zip 138.09 KB昨天16:43VIP永久 织梦模板爱搭配服装行业dedecms门户模板下载.zip 35.25 MB昨天16:43VIP永久 201