master
WuXianChaoPin 7 years ago
parent 3b8c04bf55
commit 9d36ad5abf
  1. 14
      pom-webjar.xml
  2. 2
      web/src/main/java/web/controller/CommentController.java
  3. 2
      web/src/main/java/web/controller/MenuController.java
  4. 4
      web/src/main/webapp/WEB-INF/jsp/head.jsp
  5. 13
      web/src/main/webapp/WEB-INF/jsp/index.jsp
  6. 56
      web/src/main/webapp/WEB-INF/jsp/menu.jsp
  7. 11
      web/src/main/webapp/WEB-INF/jsp/table.jsp
  8. 36
      web/src/main/webapp/WEB-INF/jsp/test.jsp
  9. 9
      web/src/test/java/SpringTest.java
  10. 3
      web/src/test/java/web/controller/TestController.java

@ -13,8 +13,7 @@
<jquery.version>RELEASE</jquery.version> <jquery.version>RELEASE</jquery.version>
<bootstrap.version>RELEASE</bootstrap.version> <bootstrap.version>RELEASE</bootstrap.version>
<fontawesome.version>RELEASE</fontawesome.version> <fontawesome.version>RELEASE</fontawesome.version>
<metisMenu.verison>RELEASE</metisMenu.verison> <jquery-tmpl.version>RELEASE</jquery-tmpl.version>
</properties> </properties>
<dependencies> <dependencies>
@ -45,11 +44,16 @@
<dependency> <dependency>
<groupId>org.webjars</groupId> <groupId>org.webjars</groupId>
<artifactId>metisMenu</artifactId> <artifactId>jquery-tmpl</artifactId>
<version>${metisMenu.verison}</version> <version>${jquery-tmpl.version}</version>
<exclusions>
<exclusion>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("/comment") @RequestMapping("/comment")
public class CommentController extends BaseController<DataModel>{ public class CommentController extends BaseController<DataModel>{
@Override @Override
public boolean checkAction(DBAction action) { public boolean checkAction(DBAction action) {
return true; return true;

@ -15,7 +15,7 @@ public class MenuController extends BaseController<MenuModel> {
@RequestMapping @RequestMapping
public <T extends AbstractModel> String find(Model model, MenuModel queryCommand, @RequestParam Integer firstResult, @RequestParam Integer maxResults){ public <T extends AbstractModel> String find(Model model, MenuModel queryCommand, @RequestParam Integer firstResult, @RequestParam Integer maxResults){
model.addAttribute("menus", super.find(DBAction.R, queryCommand, firstResult, maxResults).toString()); model.addAttribute("menus", super.find(DBAction.R, queryCommand, firstResult, maxResults).toString());
return "/menu"; return "menu";
} }
@Override @Override

@ -13,7 +13,6 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="爬虫网站">
<meta name="author" content="1029559041@qq.com"> <meta name="author" content="1029559041@qq.com">
<title>WebCrawler</title> <title>WebCrawler</title>
@ -22,7 +21,7 @@
<link href="/webjars/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"> <link href="/webjars/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts --> <!-- Custom Fonts -->
<link href="/webjars/font-awesome/5.0.10/web-fonts-with-css/css/fontawesome-all.min-jsf.css" rel="stylesheet" type="text/css"> <link href="/webjars/font-awesome/5.0.13/web-fonts-with-css/css/fontawesome-all.min-jsf.css" rel="stylesheet" type="text/css">
<!-- jQuery --> <!-- jQuery -->
<script src="/webjars/jquery/3.3.1-1/jquery.min.js"></script> <script src="/webjars/jquery/3.3.1-1/jquery.min.js"></script>
@ -31,6 +30,7 @@
<script src="/webjars/bootstrap/4.1.0/js/bootstrap.bundle.min.js"></script> <script src="/webjars/bootstrap/4.1.0/js/bootstrap.bundle.min.js"></script>
<script src="/webjars/jquery-tmpl/beta1.0.0/jquery.tmpl.min.js"></script>
<![endif]--> <![endif]-->

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!--输出,条件,迭代标签库-->
<%@ page pageEncoding="utf-8"%> <%@ page pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!--输出,条件,迭代标签库-->
<head> <head>
<c:import url="head.jsp"/> <c:import url="head.jsp"/>
<script> <script>
@ -31,11 +31,12 @@
$(this).addClass('active'); $(this).addClass('active');
$(this).siblings().removeClass('active'); $(this).siblings().removeClass('active');
$($(this).attr('href')).addClass('active show');
$($(this).attr('href')).siblings().removeClass('active show');
$("#menu" + $(this).data('id')).addClass('active show'); iframe=$('#iframe_'+$(this).data("id"));
$("#menu" + $(this).data('id')).siblings().removeClass('active show'); iframe.addClass('active show');
iframe.siblings().removeClass('active show');
}); });
$("#tabs").on('click', 'i', function () { $("#tabs").on('click', 'i', function () {
@ -48,6 +49,8 @@
} }
button.remove(); button.remove();
$('#iframe_'+button.data("id")).remove();
}); });
}); });
</script> </script>

@ -7,9 +7,33 @@
--%> --%>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!--输出,条件,迭代标签库-->
<%@ page pageEncoding="utf-8"%> <%@ page pageEncoding="utf-8"%>
<head> <head>
<script id="a_tmpl" type="text/x-jquery-tmpl">
<a href="#" class="list-group-item list-group-item-action list-group-item-success" id="menu{{= id}}" data-id="{{= id}}" data-name="{{= name}}" data-href="{{= href}}"></a>
</script>
<script id="span_tmpl" type="text/x-jquery-tmpl">
{{if length>0}}
{{= name}}<span class="badge badge-primary badge-pill">{{= length}}</span><i class="fas fa-angle-right"></i>
{{else}}
<span class="d-inline-block col-6 text-right">{{= name}}</span><span class="d-inline-block col-6 text-right"><i class="fas fa-adjust"></i></span>
{{/if}}
</script>
<script id="button_tmpl" type="text/x-jquery-tmpl">
<button type="button" id="btn_{{= id}}" class="btn btn-secondary btn-lg" data-id="{{= id}}">
{{= name}}
<i class="fas fa-times" style="display: none"></i>
</button>
</script>
<script> <script>
function showMenu() { function showMenu() {
var child = $("." + $(this).attr("id")); var child = $("." + $(this).attr("id"));
@ -39,30 +63,32 @@
for (var menu in menus) { for (var menu in menus) {
id = menus[menu].id; id = menus[menu].id;
menuId = '#menu' + id;
$("#list-tab").append('<a class="list-group-item list-group-item-action" id="' + menuId.substr(1) + '" data-toggle="list" data-href="'+menus[menu].href+'">\n' + menuId=$("#a_tmpl").tmpl({'id':id,'name':menus[menu].menuName,'href':menus[menu].href}).appendTo('.list-group');
' <span class="d-inline-block col-6 text-right">' + menus[menu].menuName + '</span>\n' +
' </a>');
if (menus[menu].menuLevel > 0) { if (menus[menu].menuLevel > 0) {
$(menuId).addClass('offset-' + menus[menu].menuLevel).addClass('menu' + menus[menu].parentId); menuId.addClass('offset-' + menus[menu].menuLevel).addClass('menu' + menus[menu].parentId);
$(menuId).hide(); menuId.hide();
} }
$("#span_tmpl").tmpl({'name':menus[menu].menuName,'length':menus[menu].childMenu.length}).appendTo(menuId);
if (menus[menu].childMenu.length > 0) { if (menus[menu].childMenu.length > 0) {
$(menuId).append('<i class="fas fa-angle-right"></i><span class="badge badge-primary badge-pill offset-8">' + menus[menu].childMenu.length + '</span>').click(showMenu); menuId.click(showMenu);
addMenu(menus[menu].childMenu,menus[menu].href); addMenu(menus[menu].childMenu,menus[menu].href);
} else { } else {
// $(menuId+'>span:last').append('<i class="fas fa-adjust"></i>'); menuId.click(function () {
$(menuId).click(function () { btnId = '#btn_' + $(this).data('id');
btnId = '#btn' + $(this).attr('id');
if ($(btnId).length == 0) { if ($(btnId).length == 0) {
$("#tabs").append('<button type="button" id="' + btnId.substr(1) + '" class="btn btn-secondary btn-lg" data-id="' + $(this).attr('id') + '" href="#iframe' + $(this).attr('id') + '">' + $(this).text() + '\n' + $("#tabs").append('<button type="button" id="' + btnId.substr(1) + '" class="btn btn-secondary btn-lg" data-id="' + $(this).data('id') + '">' + $(this).text() + '\n' +
' <i class="fas fa-times" style="display: none"></i>\n' + ' <i class="fas fa-times" style="display: none"></i>\n' +
' </button>') ' </button>')
} }
$(btnId).click(); $(btnId).click();
iframe = '#iframe' + $(this).attr('id'); iframe = '#iframe_' + $(this).data('id');
if ($(iframe).length == 0) { if ($(iframe).length == 0) {
$(top.document).find('#nav-tabContent').append('<div id="' + iframe.substr(1) + '" class="tab-pane fade embed-responsive embed-responsive-16by9" >\n' + $(top.document).find('#nav-tabContent').append('<div id="' + iframe.substr(1) + '" class="tab-pane fade embed-responsive embed-responsive-16by9" >\n' +
' <iframe class="embed-responsive-item" src="' + $(this).data('href') + '"></iframe>\n' + ' <iframe class="embed-responsive-item" src="' + $(this).data('href') + '"></iframe>\n' +
@ -78,12 +104,14 @@
$(function () { $(function () {
addMenu(${menus}['data']); addMenu(${menus}['data']);
$("#datatmlp").tmpl()
}); });
</script> </script>
</head> </head>
<div class="show" id="navbarNavDropdown"> <div class="show" id="navbarNavDropdown">
<div class="col-2"> <div class="col-2">
<div class="list-group" id="list-tab" role="tablist"> <div class="list-group">
</div> </div>
</div> </div>

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!--输出,条件,迭代标签库-->
<%@ page pageEncoding="utf-8"%>
<head>
<c:import url="head.jsp"/>
</head>
<body>
table
</body>
</html>

@ -11,29 +11,23 @@
<%@ page pageEncoding="utf-8" %> <%@ page pageEncoding="utf-8" %>
<head> <head>
<c:import url="head.jsp"/> <c:import url="head.jsp"/>
<script id="demo" type="text/x-jquery-tmpl">
<a href="#" class="list-group-item list-group-item-action list-group-item-{{= type}}">A simple {{= type}} list group item</a>
</script>
<script type="text/javascript">
$(function () {
$("#demo").tmpl([{type: 'primary'}, {type: 'secondary'}, {type: 'success'}, {type: 'danger'}, {type: 'warning'}, {type: 'info'}, {type: 'light'}, {type: 'dark'}]).appendTo('#div_demo');
});
</script>
</head> </head>
<body> <body>
<div class="container-fluid"> <div id="div_demo">
<div class="row">
<div class="col-sm text-right">
test
</div>
<div class="col-sm">
test
</div>
<div class="col-sm">
test
</div>
<div class="col-sm">
test
</div>
<div class="col-sm">
test
</div>
<div class="col-sm">
test
</div>
</div>
</div> </div>
</body> </body>
</html> </html>

@ -14,6 +14,7 @@ import org.hibernate.criterion.Projections;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType; import org.hibernate.tool.schema.TargetType;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -26,6 +27,8 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import web.config.AppConfig; import web.config.AppConfig;
@ -64,11 +67,7 @@ public class SpringTest {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
ResultActions resultActions = this.mockMvc.perform(MockMvcRequestBuilders.get("/menu").param("firstResult","0").param("maxResults","0")); ResultActions resultActions = this.mockMvc.perform(MockMvcRequestBuilders.get("/menu").param("firstResult","0").param("maxResults","0"));
MvcResult mvcResult = resultActions.andReturn(); resultActions.andDo(MockMvcResultHandlers.print()).andReturn();
MockHttpServletResponse response=mvcResult.getResponse();
log.info(response.getErrorMessage());
String result = response.getContentAsString();
log.info("客户端获得反馈数据:\n" + result);
} }
// @Test // @Test

@ -2,14 +2,15 @@ package web.controller;
import db.DBAction; import db.DBAction;
import db.model.TaskModel; import db.model.TaskModel;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller @Controller
@RequestMapping("/test") @RequestMapping("/test")
public class TestController extends BaseController<TaskModel>{ public class TestController extends BaseController<TaskModel>{
@Override @Override
public boolean checkAction(DBAction action) { public boolean checkAction(DBAction action) {
return true; return true;

Loading…
Cancel
Save