一些普通的CRUD,值得一做的就是状态之间的切换了。停用和发布切换。
值得注意的是:在信息内容中,它可以带格式地复制内容,然后上传到我们的服务器中。
流程图:
编写JavaBean与配置文件
javaBean
package zhongfucheng.info.entity; import java.sql.Timestamp; import java.util.HashMap; import java.util.Map; public class Info implements java.io.Serializable { private String infoId; private String type; private String source; private String title; private String content; private String memo; private String creator; private Timestamp createTime; private String state; public static String INFO_STATE_PUBLIC = "1";//发布 public static String INFO_STATE_STOP = "0";//停用 public static String INFO_TYPE_TZGG = "tzgg"; public static String INFO_TYPE_ZCSD = "zcsd"; public static String INFO_TYPE_NSZD = "nszd"; public static Map<String, String> INFO_TYPE_MAP = new HashMap<String, String>(); static { INFO_TYPE_MAP.put(INFO_TYPE_TZGG, "通知公告"); INFO_TYPE_MAP.put(INFO_TYPE_ZCSD, "政策速递"); INFO_TYPE_MAP.put(INFO_TYPE_NSZD, "纳税指导"); } public Info() { } public Info(String title) { this.title = title; } public Info(String type, String source, String title, String content, String memo, String creator, Timestamp createTime, String state) { this.type = type; this.source = source; this.title = title; this.content = content; this.memo = memo; this.creator = creator; this.createTime = createTime; this.state = state; } public String getInfoId() { return this.infoId; } public void setInfoId(String infoId) { this.infoId = infoId; } public String getType() { return this.type; } public void setType(String type) { this.type = type; } public String getSource() { return this.source; } public void setSource(String source) { this.source = source; } public String getTitle() { return this.title; } public void setTitle(String title) { this.title = title; } public String getContent() { return this.content; } public void setContent(String content) { this.content = content; } public String getMemo() { return this.memo; } public void setMemo(String memo) { this.memo = memo; } public String getCreator() { return this.creator; } public void setCreator(String creator) { this.creator = creator; } public Timestamp getCreateTime() { return this.createTime; } public void setCreateTime(Timestamp createTime) { this.createTime = createTime; } public String getState() { return this.state; } public void setState(String state) { this.state = state; } }
配置文件
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="zhongfucheng.info.entity.Info" table="info"> <id name="infoId" type="java.lang.String"> <column name="info_id" length="32"/> <generator class="uuid.hex" /> </id> <property name="type" type="java.lang.String"> <column name="type" length="10" /> </property> <property name="source" type="java.lang.String"> <column name="source" length="50" /> </property> <property name="title" type="java.lang.String"> <column name="title" length="100" not-null="true" /> </property> <property name="content" type="text"> <column name="content" /> </property> <property name="memo" type="java.lang.String"> <column name="memo" length="200" /> </property> <property name="creator" type="java.lang.String"> <column name="creator" length="10" /> </property> <property name="createTime" type="java.sql.Timestamp"> <column name="create_time" length="19" /> </property> <property name="state" type="java.lang.String"> <column name="state" length="1" /> </property> </class> </hibernate-mapping>
常规增删改查
这现在对我们来说没有什么难度了,改之前写过的User模块就行了。
编写dao、编写service、编写action、编写配置文件
将配置文件加载到总配置文件中。
导入前端的JSP页面
弄完之后,简单的增删改查我们已经实现了。。
接下来就是处理一些不是常用增删改查的东西了。