首页>代码>springmvc+mybatis+lucene4文档搜索系统(支持分页)>/jfware_ssml/src/cn/ssms/controller/FileIndexController.java
package cn.ssms.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.ssms.index.InitIndex;
import cn.ssms.index.PDFIndex;
import cn.ssms.index.WordIndex;

import com.alibaba.druid.util.StringUtils;

/**
 *  创建文档索引, 包括pdf、word文档
 */
@Controller
public class FileIndexController {
	
	@Autowired
	private InitIndex initIndex;
	@Autowired
	private PDFIndex pdfi;
	@Autowired
	private WordIndex wi;
	
	@RequestMapping("fileIndex")
	public String fileIndexCreate(HttpServletRequest request){
		//获得初始化文档类型
		String flag = request.getParameter("flag");
		if(StringUtils.isEmpty(flag)){
			return "fileindex";
		}
		if(StringUtils.equals(flag, "init")){
			try {
				initIndex.init();
			} catch (IOException e) {
				e.printStackTrace();
			}
			System.out.println("索引初始化成功!");
		}else if("pdf".equals(flag)){
			try {
				pdfi.createPDFIndex(request);
			} catch (Exception e) {
				e.printStackTrace();
			}
			System.out.println("PDF索引创建成功!");
		}else if("doc".equals(flag)){
			try {
				wi.createWordIndex(request);
			} catch (IOException e) {
				e.printStackTrace();
			}
			System.out.println("WORD索引创建成功!");
		}
		return "fileindex";
	}
	
	@RequestMapping("initIndex")
	public String initIndex(HttpServletRequest request){
		//获得初始化文档类型
		String flag = request.getParameter("flag");
		if(StringUtils.isEmpty(flag)){
			return "fileindex";
		}
		return null;
	}
	
}
最近下载更多
付伟1234  LV5 2023年4月21日
dulang0210  LV1 2021年11月30日
HsiaoWang  LV2 2021年7月26日
wjh12345654321  LV14 2021年6月15日
shion994  LV6 2021年5月18日
金海环境  LV1 2021年5月11日
lodddy  LV6 2021年5月4日
小黄人1号  LV1 2021年4月15日
dsfdsaf  LV3 2021年3月29日
喵小兵  LV10 2021年3月14日
最近浏览更多
微信网友_6802139027345408  LV2 2023年12月31日
szf123  LV12 2023年8月18日
付伟1234  LV5 2023年4月21日
Ckxlnd  LV13 2022年10月20日
cfdymyj 2022年9月29日
暂无贡献等级
谢谢谢谢谢谢你  LV6 2022年7月19日
BestClever  LV32 2022年6月14日
Boss绝  LV8 2022年3月12日
dulang0210  LV1 2021年11月30日
875161553  LV1 2021年8月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友