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. 60
      web/src/main/webapp/WEB-INF/jsp/menu.jsp
  7. 11
      web/src/main/webapp/WEB-INF/jsp/table.jsp
  8. 40
      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>
<bootstrap.version>RELEASE</bootstrap.version>
<fontawesome.version>RELEASE</fontawesome.version>
<metisMenu.verison>RELEASE</metisMenu.verison>
<jquery-tmpl.version>RELEASE</jquery-tmpl.version>
</properties>
<dependencies>
@ -45,11 +44,16 @@
<dependency>
<groupId>org.webjars</groupId>
<artifactId>metisMenu</artifactId>
<version>${metisMenu.verison}</version>
<artifactId>jquery-tmpl</artifactId>
<version>${jquery-tmpl.version}</version>
<exclusions>
<exclusion>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

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

@ -15,7 +15,7 @@ public class MenuController extends BaseController<MenuModel> {
@RequestMapping
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());
return "/menu";
return "menu";
}
@Override

@ -13,7 +13,6 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="爬虫网站">
<meta name="author" content="1029559041@qq.com">
<title>WebCrawler</title>
@ -22,7 +21,7 @@
<link href="/webjars/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet">
<!-- 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 -->
<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/jquery-tmpl/beta1.0.0/jquery.tmpl.min.js"></script>
<![endif]-->

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

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

@ -7,33 +7,27 @@
--%>
<!DOCTYPE html>
<html lang="en">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!--输出,条件,迭代标签库-->
<%@ page pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!--输出,条件,迭代标签库-->
<%@ page pageEncoding="utf-8" %>
<head>
<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>
<body>
<div class="container-fluid">
<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 id="div_demo">
</div>
</body>
</html>

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

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

Loading…
Cancel
Save