java ssi_java SSI idea
開發工具idea
1.SBook.xml
/p>
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
VALUES(#title#,#author#,#total#,#price#,#isbn#,#publisher#)]]>
title=#title#,author=#author#,price=#price#,total=#total#,isbn=#isbn#,publisher=#publisher#
WHERE id=#id#]]>
View Code
2.SBook.java
packagecom.gty.ssi.model;/*** Created with IntelliJ IDEA.
* User: gaitianyu
* Date: 14-2-11
* Time: 上午10:35
* To change this template use File | Settings | File Templates.*/
public classSBook {private intid;privateString title;privateString author;private inttotal;private floatprice;privateString isbn;privateString publisher;public intgetId() {returnid;
}public void setId(intid) {this.id =id;
}publicString getTitle() {returntitle;
}public voidsetTitle(String title) {this.title =title;
}publicString getAuthor() {returnauthor;
}public voidsetAuthor(String author) {this.author =author;
}publicString getIsbn() {returnisbn;
}public voidsetIsbn(String isbn) {this.isbn =isbn;
}publicString getPublisher() {returnpublisher;
}public voidsetPublisher(String publisher) {this.publisher =publisher;
}public intgetTotal() {returntotal;
}public void setTotal(inttotal) {this.total =total;
}public void setPrice(floatprice) {this.price =price;
}public floatgetPrice(){returnprice;
}
}
View Code
3.ISBookDao.java
packagecom.gty.ssi.dao;importcom.gty.ssi.model.SBook;importorg.springframework.orm.ibatis.support.SqlMapClientDaoSupport;importjava.util.List;/*** Created with IntelliJ IDEA.
* User: gaitianyu
* Date: 14-2-11
* Time: 上午10:36
* To change this template use File | Settings | File Templates.*/
public interfaceISBookDao {public void saveBook(SBook book) throwsRuntimeException;public void deleteBook(int id) throwsRuntimeException;public ListfindBooksByPublisher(String publisher)throwsRuntimeException;public void updateBook(SBook book) throwsRuntimeException;public List findAllBook() throwsRuntimeException;public SBook findBookById(int id) throwsRuntimeException;
}
View Code
4.SBookDao
packagecom.gty.ssi.dao.impl;importcom.gty.ssi.dao.ISBookDao;importcom.gty.ssi.model.SBook;importorg.springframework.orm.ibatis.support.SqlMapClientDaoSupport;importjava.util.List;/*** Created with IntelliJ IDEA.
* User: gaitianyu
* Date: 14-2-11
* Time: 上午10:40
* To change this template use File | Settings | File Templates.*/
public class SBookDao extends SqlMapClientDaoSupport implementsISBookDao {public ListfindBooksByPublisher(String publisher)throwsRuntimeException {return this.getSqlMapClientTemplate().queryForList("findBookByPublisher", publisher);
}public void saveBook(SBook book) throwsRuntimeException {this.getSqlMapClientTemplate().insert("saveBook", book);
}public void deleteBook(int id) throwsRuntimeException {this.getSqlMapClientTemplate().delete("deleteBook", id);
}public void updateBook(SBook book) throwsRuntimeException {this.getSqlMapClientTemplate().update("updateBook", book);
}
@SuppressWarnings("unchecked")public List findAllBook() throwsRuntimeException {return this.getSqlMapClientTemplate().queryForList("findAllBook");
}public SBook findBookById(int id) throwsRuntimeException {return (SBook) this.getSqlMapClientTemplate().queryForObject("findBookById", id);
}
}
View Code
5.ISBookService.java
packagecom.gty.ssi.service;importcom.gty.ssi.model.SBook;importjava.util.List;/*** Created with IntelliJ IDEA.
* User: gaitianyu
* Date: 14-2-11
* Time: 上午10:46
* To change this template use File | Settings | File Templates.*/
public interfaceISBookService {public void saveBook(SBook book) throwsRuntimeException;public ListgetBooksByPublisher(String publisher)throwsRuntimeException;public void updateBook(SBook book) throwsRuntimeException;public List getAllBook() throwsRuntimeException;public SBook getBookById(int id) throwsRuntimeException;
}
View Code
6.SBookService.java
packagecom.gty.ssi.service.impl;importcom.gty.ssi.dao.ISBookDao;importcom.gty.ssi.model.SBook;importcom.gty.ssi.service.ISBookService;importjava.util.List;/*** Created with IntelliJ IDEA.
* User: gaitianyu
* Date: 14-2-11
* Time: 上午10:49
* To change this template use File | Settings | File Templates.*/
public class SBookService implementsISBookService {privateISBookDao sbookDao;public List getAllBook() throwsRuntimeException {returnsbookDao.findAllBook();
}public ListgetBooksByPublisher(String publisher)throwsRuntimeException {returnsbookDao.findBooksByPublisher(publisher);
}public void removeBook(int id) throwsRuntimeException {
sbookDao.deleteBook(id);
}public void saveBook(SBook book) throwsRuntimeException {
sbookDao.saveBook(book);
}public void updateBook(SBook book) throwsRuntimeException {
sbookDao.updateBook(book);
}public SBook getBookById(int id) throwsRuntimeException {returnsbookDao.findBookById(id);
}public voidsetSbookDAO(ISBookDao sbookDao) {this.sbookDao =sbookDao;
}
}
View Code
7.SBookAction.java
packagecom.gty.ssi.action;importcom.gty.ssi.model.SBook;importcom.gty.ssi.service.ISBookService;importcom.opensymphony.xwork2.ActionContext;importorg.apache.struts2.ServletActionContext;importjavax.servlet.http.HttpServletRequest;importjava.util.List;/*** Created with IntelliJ IDEA.
* User: gaitianyu
* Date: 14-2-11
* Time: 上午10:53
* To change this template use File | Settings | File Templates.*/
public classSBookAction {privateISBookService sbookService;privateSBook sbook;privateString tips;privateString bookId;
@SuppressWarnings("unchecked")privateList bookList;
@SuppressWarnings("unchecked")privateList personList;publicString addSBook() {
String result= "error";try{
sbookService.saveBook(sbook);
result= "success";
}catch(Exception e) {
e.printStackTrace();
}returnresult;
}publicString viewSBook() {
String result= "error";try{
bookList=sbookService.getAllBook();
result= "success";
}catch(Exception e) {
e.printStackTrace();
}returnresult;
}publicString modifySBook() {
String result= "error";try{
sbook= sbookService.getBookById(Integer.parseInt(this.getBookId()));
result= "success";
}catch(Exception e) {
e.printStackTrace();
}returnresult;
}publicString updateSBook(){
String result= "error";
HttpServletRequest request=ServletActionContext.getRequest();
String bookid=request.getParameter("bookid");
System.out.printf("圖書編碼:"+bookid);try{
System.out.printf(sbook.getAuthor());
sbookService.updateBook(sbook);
result= "success";
}catch(Exception e){
e.printStackTrace();
}returnresult;
}publicString removeSBook(){
String result= "error";try{//sbookService.removeBook(Integer.parseInt(this.getBookId()));
result = "success";
}catch(Exception e){
e.printStackTrace();
}returnresult;
}publicSBook getSbook() {returnsbook;
}public voidsetSbook(SBook sbook) {this.sbook =sbook;
}public voidsetSbookService(ISBookService sbookServices) {this.sbookService =sbookServices;
}
@SuppressWarnings("unchecked")publicList getBookList() {returnbookList;
}
@SuppressWarnings("unchecked")public voidsetBookList(List bookList) {this.bookList =bookList;
}publicString getTips() {returntips;
}public voidsetTips(String tips) {this.tips =tips;
}publicString getBookId() {returnbookId;
}public voidsetBookId(String bookId) {this.bookId =bookId;
}
}
View Code
8.applicationContext.xml
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
View Code
9.applicationContext-action.xml
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
View Code
10.applicationContext-services.xml
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
View Code
11.dataAccessContext.xml
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
View Code
12.sqlMapConfig.xml
/p>
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
View Code
13.sbookAction.xml
/p>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
/addBook.jsp
/addBook.jsp
/viewBook.jsp
/viewBook.jsp
/bookMsg.jsp
/bookMsg.jsp
viewSBook
/bookMsg.jsp
viewSBook
viewSBook
View Code
14.struts.xml
/p>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
View Code
15.web.xml
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
contextConfigLocation
WEB-INF/classes/com/gty/ssi/config/applicationContext.xml
WEB-INF/classes/com/gty/ssi/config/applicationContext-action.xml
WEB-INF/classes/com/gty/ssi/config/applicationContext-services.xml
WEB-INF/classes/com/gty/ssi/config/dataAccessContext.xml
org.springframework.web.context.ContextLoaderListener
struts2
org.apache.struts2.dispatcher.FilterDispatcher
struts2
/*
index.jsp
View Code
addBook.jsp
添加圖書/sbook/viewSBook.action">查看現有圖書
View Code
bookMsg.jsp
修改圖書信息SBook sBook=(SBook) ovs.findValue("sbook");%>
${id}
${title}
${author}
${price}
${total}
${isbn}
${publisher}
View Code
index.jsp
圖書管理頁面添加圖書test瀏覽圖書
View Code
viewBook.jsp
瀏覽圖書庫存圖書
/addBook.jsp">添加新書
書名作者價格庫存量ISBN號出版社操作/sbook/modifySBook.action?bookId=${id}">修改信息
/sbook/removeSBook.action?bookId=${id}">刪除
客戶信息
編碼姓名性別年齡地址View Code
總結
以上是生活随笔為你收集整理的java ssi_java SSI idea的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android封装含有通用标题栏的基类B
- 下一篇: 潮汐预测 (长期预报的方法,数据为中期)