首页产品展示

master
jyx 7 years ago
parent 04c603f066
commit c07620d375

@ -54,8 +54,9 @@ public class SearchServiceController{
public List<Product> showPro(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
List<Product> products = productSearchService.findByCount();
response.setCharacterEncoding("utf-8");
System.out.println(products);
return products;
//String json = JSONObject.toJSONString(list);
// response.getWriter().print(json);
//response.getWriter().print(json);
}
}

@ -8,8 +8,54 @@
<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
<meta content="telephone=no" name="format-detection"/>
<link href="css/index.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery.min.js" ></script>
<script type="text/javascript" src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js" ></script>
<script type="text/javascript" src="js/slider.js" ></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
url: "http://localhost:8080/search/count",
type: "post",
dataType: "json",
success: function(data){
/*这个方法里是ajax发送请求成功之后执行的代码*/
showData(data);//我们仅做数据展示
},
error: function(msg){
alert("ajax连接异常"+msg);
}
});
});
//展示数据
function showData(data) {
$("#num").empty();
for (var i = 0; i < data.length; i++) {
var str=" <h2 >"+data[i].productName+"</h2>"
//var $h2 =$(str);
$("#num").append(str);
}
}
function AutoScroll(obj) {
$(obj).find("ul:first").animate({
marginTop: "-22px"
}, 500, function() {
$(this).css({
marginTop: "0px"
}).find("li:first").appendTo(this);
});
}
$(document).ready(function() {
setInterval('AutoScroll("#aui-show")', 3000)
});
</script>
</head>
<body>
@ -115,9 +161,14 @@
</div>
</div>
<div class="divHeight" ></div>
<div>
<table id = "tab"></table>
</div>
<div class="aui-borrow-head">
<div class="aui-borrow-head-title">
<div id="num"></div>
</div>
<div class="aui-borrow-head-ad">
<img src="">
</div>
</div>;
<!--<div class="aui-borrow-head-title">-->
<!--<h2>标题1</h2>-->
<!--</div>-->
@ -164,55 +215,6 @@
</a>
</footer>
</section>
<script type="text/javascript">
function AutoScroll(obj) {
$(obj).find("ul:first").animate({
marginTop: "-22px"
}, 500, function() {
$(this).css({
marginTop: "0px"
}).find("li:first").appendTo(this);
});
}
$(document).ready(function() {
setInterval('AutoScroll("#aui-show")', 3000)
});
$(function () {
$.ajax({
url: "/search/showIndex",
type: "post",
dataType: "json",
success: function(data){
/*这个方法里是ajax发送请求成功之后执行的代码*/
showData(data);//我们仅做数据展示
},
error: function(msg){
alert("ajax连接异常"+msg);
}
});
});
//展示数据
function showData(data) {
var str = "";//定义用于拼接的字符串
for (var i = 0; i < data.length; i++) {
str= " <div class=\"aui-borrow-head\">\n" +
" <div class=\"aui-borrow-head-title\">\n" +
" <h2>"+data[i].productNum+"</h2>\n" +
" </div>\n" +
" <div class=\"aui-borrow-head-ad\">\n" +
" <img src=\"\">\n" +
" </div>\n" +
" </div>";
// str = "<tr><td>"+data[i].productNum+"</td></tr>";
//追加到table中
$("#tab").append(str); }
}
</script>
</body>
</html>

@ -45,7 +45,7 @@
<div class="aui-list-head" id="proname">产品1</div>
<div class="aui-flex">
<div class="aui-flex-box">
<h4>1111</h4>
<h4 >1111</h4>
</div>
<div class="aui-text-time"> </div>

Loading…
Cancel
Save