软件工程实践记录p1(day1-3)

  在这个小学期里,我们将在学校从公司请来的老师的教导下开发一整套客户信息管理系统。这套系统可以从网页上收集客户信息到数据库管理,这次集齐了网站前端,后端java,数据库管理及中间的配置,对我来说是个比较大的考验。

前三天主要文件总汇图

 

结果效果图

 

 

第一天主要在老师的带领下,安装MyEclipseMySQL软件并进行配置。并添加数据库。

 Web.xml文件添加内容: 

<filter>

 <filter-name>struts2</filter-name>

 <filter-class>

    org.apache.struts2.dispatcher.FilterDispatcher

 </filter-class>

  </filter>

  

  <filter-mapping>

    <filter-name>struts2</filter-name>

    <url-pattern>/*</url-pattern>

  </filter-mapping>

 

  <listener>

    <listener-class>

      org.springframework.web.context.ContextLoaderListener

    </listener-class>

  </listener>

 

 applicationContext.xml文件增加部分内容:

<!--数据库-配置数据连接池 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/dbssh">
</property>
<property name="username" value="root"></property>
<property name="password" value="123456"></property>
<property name="maxActive" value="100"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>

 

第二天则是编写系统(增删查改)四个功能

com.crm.dao.CustDao.java文件部分内容:

public interface CustDao {
/**
* 保存客户信息
* @param cust
*/
public void saveCustomer(Cust cust);
/**
* 删除客户信息
* @param cust
*/
public void removeCustomer(Cust cust);
/**
* 更改客户信息
* @param id
* @return
*/
public Cust findCustomerBYID(Integer id);
/**
* 查找客户信息
* @return
*/
public List<Cust> findAllCust();
}

 

第三天则开始设计网页 ,连接数据库

custSave.jsp文件内容(后有更改,与图不符):

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!-- 下拉菜单 -->
<s:action name="typeAction" id="list"></s:action>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>新增客户信息</title>
<style>
.divcss5{width:600px;height:100px;border:1px solid #000} 
</style>
</head>
<body>
<CENTER>
<div><font size="5" color="red">新增客户信息</font></div>
<center></center>
<div style="width:20px"></div>
<div class="divcss5"> 
<s:form action="saveCustomer" theme="simple">
<div style="width:10px"></div>
客户编号:<s:textfield name="customer.custno" label="custno"></s:textfield>
客户名称:<s:textfield name="customer.custname" label="custname"></s:textfield>
客户电话:<s:textfield name="customer.telephone" label="telephone"></s:textfield><br>
<tr><td>&nbsp;</td></tr>
<s:submit value="保存"></s:submit>
<input width="100" type = "button" id = "smt" name = "btn" value="关闭" onClick="window.close();"/>
</s:form>
</div>
<div style="width:20px"></div>
</CENTER>
</body>
</html>

 

com.crm.action.CustSaveAction.java(保存信息文件):

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!-- 下拉菜单 -->
<s:action name="typeAction" id="list"></s:action>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>新增客户信息</title>
<style>
.divcss5{width:600px;height:100px;border:1px solid #000} 
</style>
</head>
<body>
<CENTER>
<div><font size="5" color="red">新增客户信息</font></div>
<center></center>
<div style="width:20px"></div>
<div class="divcss5"> 
<s:form action="saveCustomer" theme="simple">
<div style="width:10px"></div>
客户编号:<s:textfield name="customer.custno" label="custno"></s:textfield>
客户名称:<s:textfield name="customer.custname" label="custname"></s:textfield>
客户电话:<s:textfield name="customer.telephone" label="telephone"></s:textfield><br>
<tr><td>&nbsp;</td></tr>
<s:submit value="保存"></s:submit>
<input width="100" type = "button" id = "smt" name = "btn" value="关闭" onClick="window.close();"/>
</s:form>
</div>
<div style="width:20px"></div>
</CENTER>
</body>
</html>

  经过三天的练习,不仅复习了java语句,还学会了网页设计html语句和配置文件xml,期待之后的学习体验。

posted @ 2017-06-28 21:13  夜尉迟  阅读(204)  评论(0编辑  收藏  举报