短学期(3)第三次感悟

1.修改数据的各项配置都配置好之后,点击修改还是不能修改客户信息,跳出了下图这个界面,百度之后显示这个错误是指数组超出索引,数组越界了,但还是不会修改

 

 

把<s:action name="typeAction" id="list"></s:action>删掉之后

还是出现了这个错误,之后错误页面中显示CustServiceImpl.java中的32行错误,即这边的findCustById还没配return的值

 

2.在dao中把所有的增删查改都定义了接口,实现接口要实现里面所有的方法,通过SQL语句把查询的列表全部显示出来,通过类的对象的id号把客户的一个对象显示出来,这边的接口实现都是继承的hibernate.cfg.xmlfind中需要传的是字符串

ublic class UpdatePreviewCustAction extends ActionSupport

接受前端传过来的请求,

网页中404的错误是路径错误,500的错误是属性错误

3.service要调用dao

 

 

在custInfo中,要先预览,才能修改,所以此处应先指向预览即updatePreviewCust

 

4.修改客户信息时还是不能讲客户信息修改完成

 

 

是由于UpdateCustAction.java中的方法写成了customer,导致不能修改成功

 

 

5.新增客户时,即使新增了客户的电话号码,但还是不能在查询时显示出来

cust.java中添加了下面代码之后,还是不可以

public String getTelephone() {

return telephone;

}

public void setTelephone(String telephone) {

this.telephone = telephone;

}

后来在Cust.hbm.xml<property name="telephone" type="string" column="telephone" length="20"/>这段代码移动到id中之后,再新增客户信息时,就能显示客户的电话号码了,但是由于之前的客户信息都是没有加电话号码代码之前就增加的,所以还是不能显示电话号码。

 

6.之后我们开始做小组项目,我们主要做库存管理

做项目的步骤为:1.搭建环境SSH

                2.写配置文件

                3.分层实现:BeanJava.class,xxx.hbm.xml

Dao:Dao接口,Dao实现

Serviceservice接口,service实现

ActionActionServiceDao

hql语句不是SQL语句,需要写String hql = "from Cust cust order by cust.id desc";

订单管理,可以分为订单编号,商品名称,商品价格,支付方式,客户姓名,联系方式,送货地址。这边的支付方式有在线支付,微信,货到付款等,时间可以有两种表达方式:

1.Date yyyy/xxxxdd

2.time 时分秒

多线程,是指多个用户一起点击某个功能时,每个用户都可以使用

 

7.库存管理的需求分析

就像超市里面,老板要知道哪些货物要下架,哪些货物要增加,库存等等

1.商品编号

2.商品名称

3.商品价格

4.进货渠道

5.进货时间

 

这个问题是因为没有将自己的工程hxytest部署到Tomcat 6.x中去

 

 

8.后来出现了Could not parse mapping document from input stream这个错误

映射错误,因为没网,所以在applicationContext.xml中的链接mysql时链接不上

 

9.页面中的修改没必要再启动一次

10.下面我们学习了如何自动生成Excel表格

 

 

配置完之后,还是不能生成Excel文件

后来发现是没有在kcInfo.java中配置 

function funExcel(){

   location.href='generateExcel.action';

 }

 

11.applicationContext.xml中的id是前端,class是后端,idStruts中的class相对应,Struts中的name是自己取的名字,表示将做什么动作

applicationContext.xml配置的是访问路径

index.jsp是网页的代码,即网页脚本语言,用于嵌入到网页中使用

 

学习了这么多天,我大概学会了如何写增删改查使得可以在网页中使用想这些操作,大概了解了ssh架构的搭建,还学会了如何将网页中的表格生成excel文件

 

12.配置完之后的struts.xml

<?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="kc" extends="struts-default">

 

<!-- 保存 -->   

<action name="saveKc" class="kcSaveAction">

    <result name="success" type="redirect">jsp/kcInfo.jsp</result>    

<result name="input">/jsp/kcInfo.jsp</result>

</action>

 

<!-- 查询 -->

<action name="listKc" class="kcListAction">

<result>/jsp/kcInfo.jsp</result>

</action>

 

<!-- 删除 -->

<action name="delectKc" class="kcRemoveAction">

<result>/jsp/kcInfo.jsp</result>

</action>

 

<!-- 条件查询 -->

<action name="findCdtKcList" class="findCdtAction">

<result>/jsp/kcInfo.jsp</result>

</action>

 

<!-- typeAcion下拉列表 -->

<action name="typeAction" class="typeAction">

<result></result>

</action>

 

<!-- 修改预览 -->

        <action name="updatePreviewkc" class="updatePreviewKcAction">

    <result name="success">/jsp/kcUpdate.jsp</result>

        </action>

 

<!-- 修改 -->

        <action name="kcUpdate" class="updateKcAction">

        <result name="success" type="redirect">listKc.action</result>

       <result name="input">/jsp/kcUpdate.jsp</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="AllKc.xls"</param>

 <param name="inputName">downloadFile</param>

</result>

</action>

</package>

</struts>

配置完之后的applicationContext.xml

<?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/Kc.hbm.xml</value>

</list>

</property>

</bean>

<!--配置DAO-->

<bean id="kcDao" class="com.crm.impl.KcDaoImpl">

<property name="sessionFactory">

<ref bean="sessionFactory"/>

</property>

</bean>

<!--配置service  -->

<bean id="kcService" class="com.crm.service.impl.KcServiceImpl">

<property name="kcDao" ref="kcDao"></property>

</bean>

 

<!--配置-新增saveAction  -->

<bean id="kcSaveAction" class="com.crm.action.KcSaveAction">

<property name="service">

<ref bean="kcService"/>

</property>

</bean>

<!--配置-查询listAction  -->

<bean id="kcListAction" class="com.crm.action.KcListAction">

<property name="service" ref="kcService"></property>

</bean>

<!--配置-删除removeAction  -->

<bean id="kcRemoveAction" class="com.crm.action.KcRemoveAction">

<property name="service" ref="kcService"></property>

</bean>

<!--配置-条件查询findCdtAction  -->

<bean id="findCdtAction" class="com.crm.action.FindKcByCdtAction">

<property name="findCdtService" ref="kcService"></property>

</bean>

    <!--配置-typeAction  -->

<bean id="typeAction" class="com.crm.action.TypeAction">

</bean>

<!--配置-修改预览updatePreviewAction  -->

<bean id="updatePreviewKcAction" class="com.crm.action.UpdatePreviewKcAction">

<property name="updatePreviewKcService" ref="kcService"></property>

</bean>

 

<!--配置-修改updateKcAction  -->

<bean id="updateKcAction" class="com.crm.action.UpdateKcAction">

<property name="updateKcService" ref="kcService"></property>

</bean>

<!-- 导出excel -->

    <bean id="generateExcelAction" class="com.crm.action.GenerateExcelAction" scope="prototype">

    <property name="excelService">

      <ref bean="kcService"></ref>

    </property>

    </bean>

</beans>

配置完之后的index.jsp

<%@ 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>库存管理界面</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">

-->

  </head>

  <body background="images/2.jpg">

  <body>

  <br><br><br><br><br><br><br><br>

  <!--<div><h1>库存管理界面</h1><br></div>

    <form action="" styles=""><font size="10" color="red">ssh-test-集成环境测试</font></form></center>-->

  <center>

  <div class="divcss5">

  <center><h1><font color="red" size="7" face="Arabic Typesetting">操作列表</font></h1><br>

  <s:a href="jsp/kcInfo.jsp"><font face="Aparajita"><strong><font size="5">库存信息管理</font></strong></font></s:a><br><br>

  <s:a href="jsp/kcInfo.jsp"><font face="Aparajita"><strong><font size="5">查询库存信息</font></strong></font></s:a></center>

  </div><br>

  </center>

  </body>

</html>

还有其他的action中要对增删查改动作的写入,以及各个,全部配置完之后打开网页之后出现的界面,还有点击生成excel的按键出现的界面

 

 

 

可以根据自己的想法对此表格进行操作。

 

posted @ 2017-07-05 19:20  来一只包子  阅读(156)  评论(0编辑  收藏  举报