• 大小: 1.23MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-28
  • 语言: 其他
  • 标签: springsolr  

资源简介

spring整合 solr部署到Tomcat,spring整合 solr部署到Tomcat

资源截图

代码片段和文件信息

package cn.ssmsr.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.ssmsr.filter.FileUtil;
import cn.ssmsr.po.Jd;
import cn.ssmsr.service.Searchservice;
import cn.ssmsr.service.jdproductService;
@Controller
public class jdproductController {
@Autowired
private Searchservice searchservice;
@Autowired
private jdproductService jdproductservice;
/**
 * 根据电脑关键字查询所有商品标题包含电脑的商品
 * @return
 */
@RequestMapping(“query“)
public ModelAndView jddnproductquer(){
//搜索关键字(一般是用户输入在这我没写用户输入的那个页面了直接写上了)
SolrDocumentList solrdocument=searchservice.Searchproduct(“电脑“);
long sumnumber=solrdocument.getNumFound();
List jdlist=new ArrayList();
for(SolrDocument doc :solrdocument){
Jd jd=new Jd();
jd.setId(Integer.parseInt(doc.get(“id“).toString()));
jd.settitle(doc.get(“title“).toString());
jd.setlink(doc.get(“link“).toString());
jd.setPrice(Integer.parseInt(doc.get(“price“).toString()));
jd.setComment(Integer.parseInt(doc.get(“goodcomment“).toString()));
jd.setPoorcountstr(Integer.parseInt(doc.get(“poorcountstr“).toString()));
jd.setAftercount(Integer.parseInt(doc.get(“aftercount“).toString()));
jdlist.add(jd);
//System.out.println(“id:“+doc.get(“id“)+“title:“+doc.get(“title“)+“link:“+doc.get(“link“)+“price:“+doc.get(“price“));
}
ModelAndView model=new ModelAndView();
model.addobject(“number“sumnumber);
model.addobject(“jdlist“jdlist);
model.setViewName(“jsp/jdlist“);
//System.out.println(“执行到这了2“);
return model;
}
/**
 * 根据id查询商品实体(id是由solr那边来的是String类型)
 * @param id
 * @return
 */
@RequestMapping(“findjdbyid“)
public ModelAndView selectproductbyid(String id){
FileUtil utile=new FileUtil();
//判断是否是数字
boolean suz=utile.isNumeric(id);
Jd jd=null;
if(suz){
int productid=Integer.parseInt(id);
 jd=jdproductservice.findJd(productid);
}
ModelAndView model=new ModelAndView();
model.addobject(“jdst“jd);
model.setViewName(“jsp/jddat“);
return model;
}
/**
 * 根据id删除商品
 * @param id
 * @return
 */
@RequestMapping(“deleteproduct“)
public ModelAndView deleteproductbyid(String id){
FileUtil utile=new FileUtil();
boolean suz=utile.isNumeric(id);
if(suz){
int productid=Integer.parseInt(id);
//根据索引id删除索引
searchservice.queryDeleteDoc(id);
int fhz=jdproductservice.deleteJd(productid);
}
ModelAndView model=new ModelAndView(“redirect:/query“);
return model;
}
@RequestMapping(“addtzproduct“)
public ModelAndView tzproduct(){
ModelAndView model=new ModelAndView();
model.setViewName(“jsp/addproduct“);
return model;
}
/**
 * 添加商品 
 */
@RequestMapping(“addproduct“)
public ModelAndView

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\
     文件        1621  2017-06-12 09:03  SolrRedissolrdemo-master\.classpath
     文件           9  2017-06-12 09:03  SolrRedissolrdemo-master\.gitignore
     文件        1184  2017-06-12 09:03  SolrRedissolrdemo-master\.project
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\
     文件         626  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\.jsdtscope
     文件         422  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.jdt.core.prefs
     文件          86  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.m2e.core.prefs
     文件         765  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.wst.common.component
     文件         245  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.wst.jsdt.ui.superType.name
     文件          48  2017-06-12 09:03  SolrRedissolrdemo-master\.settings\org.eclipse.wst.validation.prefs
     文件        4785  2017-06-12 09:03  SolrRedissolrdemo-master\pom.xml
     文件         359  2017-06-12 09:03  SolrRedissolrdemo-master\redame.txt
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\controller\
     文件        3454  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\controller\jdproductController.java
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\filter\
     文件         674  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\filter\CustomDateDonverter.java
     文件         485  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\filter\CustomDoubleDonverter.java
     文件        3458  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\filter\ExcelUtil.java
     文件         482  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\filter\FileUtil.java
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\mapper\
     文件         740  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\mapper\JdMapper.java
     文件        9379  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\mapper\JdMapper.xml
     目录           0  2017-06-12 09:03  SolrRedissolrdemo-master\src\main\java\cn\ssmsr\po\
............此处省略38个文件信息

评论

共有 条评论

相关资源