思维导图
先给界面中添加Tabs选项卡
$(function() {
$("#bookMenus").tree({
url:$("#ctx").val()+"/permission.action?methodName=tree",
onClick: function(node){
var exists=$("#bookTabs").tabs('exists',node.text);
if(exists){
$("#bookTabs").tabs('select',node.text);
}else{
$('#bookTabs').tabs('add',{
title:node.text,
content:'<iframe width="100%" height="100%" src="'+$("#ctx").val()+node.attributes.self.url+'"/>',
closable:true
});
}
}
});
})
一.书籍类别下拉框
①实体类,dao包以及web包
package com.lsy.entity;
public class Category {
private long id;
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Category [id=" + id + ", name=" + name + "]";
}
}
dao包(查出所有类别)
package com.lsy.dao;
import java.util.List;
import com.lsy.entity.Category;
import com.zking.util.BaseDao;
import com.zking.util.PageBean;
public class CategoryDao extends BaseDao<Category>{
public List<Category> list(Category category, PageBean pageBean) throws Exception {
String sql="select * from t_easyui_category";
return super.executeQuery(sql, Category.class, pageBean);
}
}
web包
package com.lsy.web;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lsy.dao.CategoryDao;
import com.lsy.entity.Category;
import com.zking.framework.ActionSupport;
import com.zking.framework.ModelDriver;
import com.zking.util.ResponseUtil;
public class CategoryAction extends ActionSupport implements ModelDriver<Category>{
private Category category=new Category();
private CategoryDao categoryDao=new CategoryDao();
@Override
public Category getModel() {
return category;
}
/**
* 书籍类别下拉框
* @param req
* @param resp
* @return
*/
public String combobox(HttpServletRequest req, HttpServletResponse resp) {
try {
List<Category> list = categoryDao.list(category, null);
ResponseUtil.writeJson(resp, list);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
配置xml文件
<action path="/category" type="com.lsy.web.CategoryAction">
</action>
addBook.jsp界面代码
$(function () {
$('#cid').combobox({
url:'${pageContext.request.contextPath}/category.action?methodName=combobox',
valueField:'id',
textField:'name'
});
});
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>书籍新增</title>
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}/static/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/js/easyui/themes/icon.css">
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/static/js/easyui/jquery.easyui.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/main.js"></script>
</head>
<body>
<div style="margin:20px 0;"></div>
<div class="easyui-panel" title="已下架书籍" style="width:100%;padding:30px 60px;">
<form id="ff" action="" method="post">
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="name" style="width:100%" data-options="label:'书名:',required:true">
</div>
<div style="margin-bottom:20px">
<input id="cid" name="cid" value="" label="类别" >
<!-- <select class="easyui-combobox" name="cid" label="类别" style="width:100%">
<option value="1">文艺</option>
<option value="2">小说</option>
<option value="3">青春</option>
</select> -->
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="author" style="width:100%" data-options="label:'作者:',required:true">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="price" style="width:100%"
data-options="label:'价格:',required:true">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="publishing" style="width:100%"
data-options="label:'出版社:',required:true">
</div>
<div style="margin-bottom:20px">
<input class="easyui-textbox" name="description" style="width:100%;height:60px"
data-options="label:'简介:',required:true">
</div>
<%--默认未上架--%>
<input type="hidden" name="state" value="1">
<%--默认起始销量为0--%>
<input type="hidden" n