短学期第三篇
这周开始自己做项目,我做的是库存管理。每个商品包含商品编号、商品名字、商品数量、商品种类、商品价格五个基本信息。实现的功能是对商品进行增、删、改、查操作,并且可以提供一个下载EXCEL表格的功能。
代码如下:
package com.crm.action;
import java.io.InputStream;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionSupport;
public class GenerateExcelAction extends ActionSupport {
private static final long serialVersionUID = 7213178640352795420L;
private ItemService excelService;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return SUCCESS;
}
public ItemService getExcelService() {
return excelService;
}
public InputStream getDownloadFile(){
return this.excelService.getInputStream();
}
public void setExcelService(ItemService excelService) {
this.excelService = excelService;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
}
package com.crm.action;
import java.util.Map;
import com.crm.bean.Item;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ItemFindByCdAction extends ActionSupport{
private Item item;
private ItemService findCdService;
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public ItemService getFindCdService() {
return findCdService;
}
public void setFindCdService(ItemService findCdService) {
this.findCdService = findCdService;
}
public String execute() throws Exception {
// TODO Auto-generated method stub
Map map = (Map)ActionContext.getContext().get("request");
map.put("list", this.findCdService.findItemByCondition(item));
return SUCCESS;
}
}
package com.crm.action;
import java.util.Map;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class ItemListAction extends ActionSupport{
private ItemService listService;
public void setListService(ItemService listService) {
this.listService = listService;
}
@SuppressWarnings("unchecked")
@Override
public String execute() throws Exception{
Map map = (Map)ActionContext.getContext().get("request");
map.put("list",this.listService.findAllItem());
return SUCCESS;
}
}
package com.crm.action;
import com.crm.bean.Item;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionSupport;
public class ItemRemoveAction extends ActionSupport{
private Item item;
private ItemService removeService;
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public ItemService getRemoveService() {
return removeService;
}
public void setRemoveService(ItemService removeService) {
this.removeService = removeService;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
this.removeService.deleteItem(item);
return SUCCESS;
}
}
package com.crm.action;
import com.crm.bean.Item;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionSupport;
public class ItemSaveAction extends ActionSupport{
private Item item;
private ItemService saveService;
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public ItemService getSaveService() {
return saveService;
}
public void setSaveService(ItemService saveService) {
this.saveService = saveService;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
this.saveService.saveItem(item);
return SUCCESS;
}
}
package com.crm.action;
import java.util.ArrayList;
import java.util.List;
import com.crm.bean.Item;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionSupport;
public class ItemUpdateAction extends ActionSupport{
private Item item;
private ItemService updateService;
List strList = new ArrayList();
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public ItemService getUpdateService() {
return updateService;
}
public void setUpdateService(ItemService updateService) {
this.updateService = updateService;
}
public List getStrList() {
return strList;
}
public void setStrList(List strList) {
this.strList = strList;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
this.item.setItemvariety(this.strList.get(0).toString());
this.updateService.updateItem(item);
return SUCCESS;
}
}
package com.crm.action;
import com.crm.bean.Item;
import com.crm.service.ItemService;
import com.opensymphony.xwork2.ActionSupport;
public class ItemUpdatePreviewAction extends ActionSupport{
private Item item;
private ItemService updatePvService;
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
public ItemService getUpdatePvService() {
return updatePvService;
}
public void setUpdatePvService(ItemService updatePvService) {
this.updatePvService = updatePvService;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
item = this.updatePvService.findItemById(item.getId());
return SUCCESS;
}
}
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;
}
}
package com.crm.bean;
public class Item {
private int id;
private String itemnumber;
private String itemname;
private String itemamount;
private String itemvariety;
private String itemprise;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getItemnumber() {
return itemnumber;
}
public void setItemnumber(String itemnumber) {
this.itemnumber = itemnumber;
}
public String getItemname() {
return itemname;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
public String getItemamount() {
return itemamount;
}
public void setItemamount(String itemamount) {
this.itemamount = itemamount;
}
public String getItemvariety() {
return itemvariety;
}
public void setItemvariety(String itemvariety) {
this.itemvariety = itemvariety;
}
public String getItemprise() {
return itemprise;
}
public void setItemprise(String itemprise) {
this.itemprise = itemprise;
}
}
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;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.crm.bean.Item" table="item">
<id name="id" type="java.lang.Integer" column="id">
<generator class="increment"></generator>
</id>
<property name="itemnumber" type="string" column="itemnumber" length="20"/>
<property name="itemname" type="string" column="itemname" length="100"/>
<property name="itemamount" type="string" column="itemamount" length="10"/>
<property name="itemvariety" type="string" column="itemvariety" length="20"/>
<property name="itemprise" type="string" column="itemprise" length="10"/>
</class>
</hibernate-mapping>
package com.crm.dao;
import java.util.List;
import com.crm.bean.Item;
public interface ItemDao {
/**
* 保存商品信息
*/
public void saveItem(Item item);
/**
* 查询商品信息
* @param id
* @return
*/
public Item findItemById(Integer id);
/**
* 查询所有商品
* @return
*/
public List<Item> findAllItem();
/**
* 条件查询
* @param item
* @return
*/
public List<Item> findItemByCondition(Item item);
/**
* 删除商品信息
* @param item
*/
public void deleteItem(Item item);
/**
* 修改商品信息
* @param item
*/
public void updateItem(Item item);
}
package com.crm.impl;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.crm.bean.Item;
import com.crm.dao.ItemDao;
public class ItemDaoImpl extends HibernateDaoSupport implements ItemDao{
public void saveItem(Item item) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(item);
}
public List<Item> findAllItem() {
// TODO Auto-generated method stub
String hql = "from Item item order by item.id asc";
return (List<Item>)this.getHibernateTemplate().find(hql);
}
public List<Item> findItemByCondition(Item item) {
// TODO Auto-generated method stub
StringBuffer strBuffer = new StringBuffer();
String hql = "from Item item where 1=1 ";
strBuffer.append(hql);
if(item == null){
throw new NullPointerException("查询条件不能为空!");
}
if(!"".equals(item.getItemname())){
String itemname = " and itemname = '"+item.getItemname()+"'";
strBuffer.append(itemname);
}
if(!"".equals(item.getItemnumber())){
String itemname = " and itemnumber = '"+item.getItemnumber()+"'";
strBuffer.append(itemname);
}
String orderBy = " order by item.id asc";
strBuffer.append(orderBy);
List<Item> itemList = this.getHibernateTemplate().find(strBuffer.toString());
//return (List<Item>)this.getHibernateTemplate().find(strBuffer.toString());
return itemList;
}
public Item findItemById(Integer id) {
// TODO Auto-generated method stub
Item item = (Item)this.getHibernateTemplate().get(Item.class,id);
return item;
}
public void deleteItem(Item item) {
// TODO Auto-generated method stub
this.getHibernateTemplate().delete(item);
}
public void updateItem(Item item) {
// TODO Auto-generated method stub
this.getHibernateTemplate().update(item);
}
}
package com.crm.service;
import java.io.InputStream;
import java.util.List;
import com.crm.bean.Item;
public interface ItemService {
/**
* 保存商品信息
* @param item
*/
public void saveItem(Item item);
/**
* 查询商品信息
* @param id
* @return
*/
public Item findItemById(Integer id);
/**
* 查询所有商品信息
* @return
*/
public List<Item> findAllItem();
/**
* 条件查询
* @param item
* @return
*/
public List<Item> findItemByCondition(Item item);
/**
* 删除商品信息
* @param item
*/
public void deleteItem(Item item);
/**
* 更新商品信息
* @param item
*/
public void updateItem(Item item);
/**
* 生成excel
* @return
*/
public InputStream getInputStream();
}
package com.crm.service.impl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.crm.bean.Item;
import com.crm.dao.ItemDao;
import com.crm.service.ItemService;
public class ItemServiceImpl implements ItemService {
ItemDao itemDao;
public ItemDao getItemDao() {
return itemDao;
}
public void setItemDao(ItemDao itemDao) {
this.itemDao = itemDao;
}
public void saveItem(Item item) {
// TODO Auto-generated method stub
this.itemDao.saveItem(item);
}
public List<Item> findItemByCondition(Item item) {
// TODO Auto-generated method stub
return this.itemDao.findItemByCondition(item);
}
public List<Item> findAllItem() {
// TODO Auto-generated method stub
return this.itemDao.findAllItem();
}
public Item findItemById(Integer id) {
// TODO Auto-generated method stub
return this.itemDao.findItemById(id);
}
public void deleteItem(Item item) {
// TODO Auto-generated method stub
this.itemDao.deleteItem(item);
}
public void updateItem(Item item) {
// TODO Auto-generated method stub
this.itemDao.updateItem(item);
}
public InputStream getInputStream() {
// TODO Auto-generated method stub
HSSFWorkbook wb=new HSSFWorkbook();
HSSFSheet sheet=wb.createSheet("sheet1");
HSSFRow row=sheet.createRow(0);
HSSFCell cell=row.createCell((short)0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("商品编号");
cell=row.createCell((short)1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("商品名称");
cell=row.createCell((short)2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("商品数量");
cell=row.createCell((short)3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("商品种类");
cell=row.createCell((short)4);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("商品价格");
List<Item> list=this.itemDao.findAllItem();
for(int i=0;i<list.size();++i)
{
Item item=list.get(i);
row=sheet.createRow(i+1);
cell=row.createCell((short)0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(item.getItemnumber());
cell=row.createCell((short)1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(item.getItemname());
cell=row.createCell((short)2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(item.getItemamount());
cell=row.createCell((short)3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(item.getItemvariety());
cell=row.createCell((short)4);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(item.getItemprise());
}
File file=new File("item.xls");
try{
OutputStream os=new FileOutputStream(file);
wb.write(os);
os.close();
}catch(Exception e){
e.printStackTrace();
}
InputStream is=null;
try{
is=new FileInputStream(file);
}catch(FileNotFoundException e){
e.printStackTrace();
}
return is;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="item" extends="struts-default">
<!-- 保存 -->
<action name="saveItem" class="itemSaveAction">
<result name="success" type="redirect">/jsp/itemInfo.jsp</result>
<result name="input">/itemSave.jsp</result>
</action>
<!-- 查询 -->
<action name="listItem" class="itemListAction">
<result>/jsp/itemInfo.jsp</result>
</action>
<!-- 条件查询 -->
<action name="findItemByCd" class="findItemByCdAction">
<result>/jsp/itemInfo.jsp</result>
</action>
<!-- 删除 -->
<action name="deleteItem" class="itemRemoveAction">
<result>/jsp/itemInfo.jsp</result>
</action>
<!-- 修改预览 -->
<action name="updatePvItem" class="itemUpdatePreviewAction">
<result>/jsp/itemUpdate.jsp</result>
</action>
<!-- 修改 -->
<action name="updateItem" class="itemUpdateAction">
<result name="success" type="redirect">listItem.action</result>
<result name="input">/jsp/itemUpdate.jsp</result>
</action>
<!-- typeAction下拉列表 -->
<action name="typeAction" class="typeAction">
<result></result>
</action>
<!-- 导出excel -->
<action name="generateExcel" class="generateExcelAction">
<result name="success" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="contentDisposition">filename="AllItem.xls"</param>
<param name="inputName">downloadFile</param>
</result>
</action>
</package>
</struts>
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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:120px;border:1px solid #000}
body,table{
font-size:12px;
}
table{
table-layout:fixed;
empty-cells:show;
border-collapse: collapse;
margin:0 auto;
}
td{
height:30px;
}
h1,h2,h3{
font-size:12px;
margin:0;
padding:0;
}
.table{
border:1px solid #000;
color:#000;
}
.table th {
background-repeat:repeat-x;
height:30px;
}
.table td,.table th{
border:1px solid #000;
padding:0 1em 0;
}
.table tr.alter{
background-color:#000;
}
</style>
</head>
<script language="JavaScript" type="text/javascript">
function openwind(){
feature="dialogWidth:650px;dialogHeight:200px;status:no;help:no;scrollbars:no;dialogTop:150;";
window.showModalDialog("itemSave.jsp",null,feature);
};
function funDelete(){
//window.onload = alert(111);
if(confirm('确定要执行此操作吗?')){
return true;
}else{
return false;
}
};
function updatewindow(){
feature="dialogWidth:650px;dialogHeight:200px;status:no;help:no;scrollbars:no;dialogTop:150;";
window.showModalDialog("itemUpdate.jsp",null,feature);
};
function funExcel(){
location.href='generateExcel.action';
}
</script>
<body>
<CENTER>
<center><div><font color="red" size="6">库存管理系统</font></div></center>
<div style="width:20px"></div>
<div class="divcss5">
<s:form action="listItem" theme="simple">
<div style="width:10px"></div>
商品编号:<s:textfield name="item.itemnumber" label="itemnumber"></s:textfield>
商品名称:<s:textfield name="item.itemname" label="itemname"></s:textfield><br>
商品价格:<s:textfield name="item.itemprise" label="itemprise"></s:textfield>
商品类别:<s:textfield name="item.itemvariety" label="itemvariety"></s:textfield><br>
<div style="width:20px"></div>
<input width="100" type = "button" id = "add" name = "btn" value="新增" onClick="openwind();"/>
<s:submit action="findItemByCd" value="查询"> </s:submit>
<input width="100" type = "button" id = "smt" name = "btn" value="返回" onClick="history.go(-1)"/>
<input width="100" type = "button" value="生成excel" onClick="funExcel();"/>
</s:form>
</div>
<div style="width:20px"></div>
<table border="1" width="47%" class="table">
<tr>
<td>商品编号</td>
<td>商品名称</td>
<td>商品类别</td>
<td>商品价格</td>
<td>库存数量</td>
<td width="80">操作</td>
</tr>
<s:iterator value="#request.list" id="item">
<tr>
<td><s:property value="#item.itemnumber"/></td>
<td><s:property value="#item.itemname"/></td>
<td>
<s:if test="#item.itemvariety == 1">
<s:property value="'日用品'"/>
</s:if>
<s:elseif test="#item.itemvariety == 2">
<s:property value="'电子产品'"/>
</s:elseif>
<s:elseif test="#item.itemvariety == 3">
<s:property value="'其他'"/>
</s:elseif>
</td>
<td><s:property value="#item.itemprise"/></td>
<td><s:property value="#item.itemamount"/></td>
<td>
<s:a href="updatePvItem.action?item.id=%{#item.id}">修改</s:a>
<s:a href="deleteItem.action?item.id=%{#item.id}" onClick="return funDelete();">删除</s:a>
</td>
</tr>
</s:iterator>
</table>
</CENTER>
</body>
</html>
<%@ 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>
<s:form action="saveItem">
<s:textfield name="item.itemnumber" label="商品编号"></s:textfield>
<s:textfield name="item.itemname" label="商品名称"></s:textfield>
<s:textfield name="item.itemamount" label="商品数量"></s:textfield>
<s:textfield name="item.itemvariety" label="商品类别"></s:textfield>
<s:textfield name="item.itemprise" label="商品价格"></s:textfield>
<s:submit value="保存"></s:submit>
</s:form>
</center>
</body>
</html>
<%@ 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>
<script type="text/javascript">
function updatewindow(){
alert(("保存成功");
window.showModalDialog("itemUpdate.jsp",null,feature);
};
</script>
<body>
<CENTER>
<div><font size="5" color="red">修改商品信息</font></div>
<center></center>
<div style="width:20px"></div>
<div class="divcss5">
<s:form action="updateItem" theme="simple">
<div style="width:10px"></div>
商品编号:<s:textfield name="item.itemnumber" value="%{item.itemnumber}" label="itemnumber"></s:textfield>
商品类别:<s:select name="strList" headerKey="0" value="%{item.itemvariety}" headerValue="-----------请选择-----------" list="#list.strList" listKey="id" listValue="name"/><br>
商品名称:<s:textfield name="item.itemname" value="%{item.itemname}" label="itemname"></s:textfield>
商品数量:<s:textfield name="item.itemamount" label="%{item.itemamount}"></s:textfield><br>
商品价格:<s:textfield name="item.itemprise" value="%{item.itemprise}" label="itemprise"></s:textfield><br>
<s:hidden name="item.id" value="%{item.id}" ></s:hidden>
<tr><td> </td></tr>
<s:submit value="保存" onClick="window.history.back(-1);"></s:submit>
<input width="100" type = "button" id = "smt" name = "btn" value="关闭" onClick="history.go(-1);"/>
</s:form>
</div>
<div style="width:20px"></div>
</CENTER>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!--数据库-配置数据连接池 -->
<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>
<!--sessionFactory配置与管理 -->
<bean id = "sessionFactory"
class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/crm/bean/Item.hbm.xml</value>
</list>
</property>
</bean>
<!-- 配置Dao -->
<bean id = "ItemDao" class = "com.crm.impl.ItemDaoImpl">
<property name = "sessionFactory">
<ref bean = "sessionFactory"/>
</property>
</bean>
<!--配置service -->
<bean id="ItemService" class="com.crm.service.impl.ItemServiceImpl">
<property name="itemDao" ref="ItemDao"></property>
</bean>
<!--配置-新增saveAction -->
<bean id="itemSaveAction" class="com.crm.action.ItemSaveAction">
<property name="saveService" ref="ItemService"></property>
</bean>
<!--配置-查询listAction -->
<bean id="itemListAction" class="com.crm.action.ItemListAction">
<property name="listService" ref="ItemService"></property>
</bean>
<!--配置-条件查询findCdAction -->
<bean id="findItemByCdAction" class="com.crm.action.ItemFindByCdAction">
<property name="findCdService" ref="ItemService"></property>
</bean>
<!--配置-删除deleteAction -->
<bean id="itemRemoveAction" class="com.crm.action.ItemRemoveAction">
<property name="removeService" ref="ItemService"></property>
</bean>
<!--配置-修改预览updatePvAction -->
<bean id="itemUpdatePreviewAction" class="com.crm.action.ItemUpdatePreviewAction">
<property name="updatePvService" ref="ItemService"></property>
</bean>
<!--配置-修改updateAction -->
<bean id="itemUpdateAction" class="com.crm.action.ItemUpdateAction">
<property name="updateService" ref="ItemService"></property>
</bean>
<!--配置-typeAction -->
<bean id="typeAction" class="com.crm.action.TypeAction">
</bean>
<!--配置-导出excel -->
<bean id="generateExcelAction" class="com.crm.action.GenerateExcelAction" scope="prototype">
<property name="excelService" ref="ItemService"></property>
</bean>
</beans>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="styles.css">
<style>
.divcss5{
width:800px;
height:200px;
border:1px solid black;
}
</style>
</head>
<body>
<center>
<div class="divcss5">
<center>
<h1><font color="red">操作列表</font></h1>
<s:a href="jsp/itemInfo.jsp">货物信息管理</s:a><br><br><br>
<s:a href="listCompany.action">查询公司信息</s:a>
</center>
</div>
</center>
</body>
</html>
实现结果如图:

点击“货物信息管理”:

点击“新增”,并输入数据,再点击保存:

点击“查询”,会显示所有商品信息:

点击“键盘”的“修改”,修改一些信息,点击保存:

可以看到信息已被修改:

点击"生成excel",会生成一个excel表格,供下载:

对信息进行删除操作,只需点击单条信息的“删除”即可:


浙公网安备 33010602011771号