Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target/
.settings/
.project
.classpath
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@
<artifactId>jackson-databind</artifactId>
<version>2.5.4</version>
</dependency>
<!--
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
-->

<!-- 4.Spring -->
<!-- 1)Spring核心 -->
Expand Down Expand Up @@ -142,5 +144,17 @@
</dependencies>
<build>
<finalName>ssm</finalName>
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
38 changes: 37 additions & 1 deletion src/main/java/com/soecode/lyf/entity/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,44 @@ public class Book {
private String name;// 图书名称

private int number;// 馆藏数量

private String description;// 图书简介

private String press;// 出版社



public Book() {
/**
* @return the description
*/

public String getDescription() {
return description;
}

/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}

/**
* @return the press
*/

public String getPress() {
return press;
}

/**
* @param press the press to set
*/
public void setPress(String press) {
this.press = press;
}

public Book() {
}

public Book(long bookId, String name, int number) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/mapper/BookDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.soecode.lyf.dao.BookDao">
<!-- 目的:为dao接口方法提供sql语句配置 -->
<sql id="bookCol">book_id,name,number,description,press</sql>
<select id="queryById" resultType="Book" parameterType="long">
<!-- 具体的sql -->
SELECT
book_id,
name,
number
<include refid="bookCol"></include>
FROM
book
WHERE
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/spring/spring-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
(1)加入对静态资源的处理:js,gif,png
(2)允许使用"/"做整体映射
-->
<mvc:default-servlet-handler/>
<!-- 对静态资源文件的访问 -->
<mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
<mvc:resources location="/WEB-INF/css/" mapping="/css/**"/>

<!-- 3.配置jsp 显示ViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/WEB-INF/css/bootstrap.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/main/webapp/WEB-INF/js/bootstrap.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/main/webapp/WEB-INF/js/jquery-v1.10.2.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/main/webapp/WEB-INF/js/jquery.min.js

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions src/main/webapp/WEB-INF/jsp/detail.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.UUID" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>Book Detail</title>
<link href="../../css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script src="../../js/jquery.min.js" type="text/javascript"></script>
<script src="../../js/bootstrap.min.js" type="text/jscript"></script>
</head>
<body>
<br/>
<div class="box-123">
<table class="table table-bordered">
<tr>
<th>图书详情</th>
<th>..</th>
</tr>
<tbody id="cityCols">
<tr>
<td>书名</td>
<td>${book.name}</td>
</tr>
<tr>
<td>库存</td>
<td>${book.number}</td>
</tr>
<tr>
<td>简介</td>
<td>${book.description}</td>
</tr>
<tr>
<td>出版社</td>
<td>${book.press}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
75 changes: 75 additions & 0 deletions src/main/webapp/WEB-INF/jsp/list.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.UUID" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>Book List</title>
<link href="../css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<style type="text/css">
  A:link {
  color:blue; text-decoration: none
  }
  A:visited {
  color:red; text-decoration:line-through
  }
  A:active {
  color:white; text-decoration:underline
  }
  A:hover {
  color:yellow;text-decoration:none;background-color:black
  }
  </style>
<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/bootstrap.min.js" type="text/jscript"></script>
<script type="text/javascript">
function appointBook(id,studentId){
$.ajax({
url : "/ssm/book/"+id+"/appoint?studentId=1111",
type : "POST",
contentType : "application/json;charset=utf-8",
success : function(result) {
if (result.success == true) {
if(result.data){
alert(result.data.stateInfo);
}
location.reload();
}
},
error:function(msg){
alert('Error!');
}
});
};

</script>
</head>
<body>
<br/>
<div class="box-123">
<a id = "add" style='border-left: left' href='/book/add'>添加</a>
<table class="table table-bordered">
<tr>
<th>ID</th>
<th>书名</th>
<th>库存量</th>
<th>操作</th>
</tr>
<tbody id="cityCols">
<c:forEach items="${list}" var="book">
<tr>
<td>${book.bookId}</td>
<td><a id = "add" target='_blank' href='/ssm/book/${book.bookId}/detail' style='text-decoration:underline;'>${book.name}</a></td>
<td>${book.number}</td>
<td><button onclick='appointBook(${book.bookId},1111);'>预约</button></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>