PageOffice移植到springboot的几个问题解决

移植Pageoffice到公司的springboot平台,列出一些遇到的问题和解决方法。
1、 访问pageoffice url的操作被shiro拦截。解决办法修改shiro配置文件,将controller类名字(这里的类名是pageoffice),和后缀为zz的url取消拦截。安全起见token改为前后端分离的方式获取。

@Bean("shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
	... ...
	filterMap.put("/**/*.zz", "anon");        
	filterMap.put("/pageoffice/**", "anon");           
	... ...
	return shiroFilter;
}

2、 Pageoffice的url要加入context-path,如果有这个定义。
这里面是blc 例如poCtrl.setServerPage("/blc/poserver.zz");
下面是application.yml文件

server:
    tomcat:
    context-path: /blc

3、 servletRegistrationBean8()函数名字要注意,避免和Druid 数据库连接池的servletRegistrationBean函数名重复。
controller代码如下

@RestController
@RequestMapping("/pageoffice")
public class OpenDocController {
	@Value("${pageoffice.posyspath}")
	private String poSysPath;
	@Value("${pageoffice.popassword}") 
	private String poPassWord;
	@RequestMapping(value="/openfile")
	public ModelAndView showIndex(){	
		ModelAndView mv = new ModelAndView("Index");
		return mv;
	}
	@RequestMapping(value="/word")
	public ModelAndView showWord(HttpServletRequest request, Map<String,Object> map){
		PageOfficeCtrl poCtrl=new PageOfficeCtrl(request);
		poCtrl.setServerPage("/blc/poserver.zz");//设置服务页面
		poCtrl.addCustomToolButton("保存","Save",1);//添加自定义保存按钮
		poCtrl.addCustomToolButton("盖章","AddSeal",2);//添加自定义盖章按钮
		poCtrl.setSaveFilePage("/blc/pageoffice/save");//设置处理文件保存的请求方法
		//打开word
		poCtrl.webOpen("d:\\test.doc",OpenModeType.docAdmin,"张三");
		map.put("pageoffice",poCtrl.getHtmlCode("PageOfficeCtrl1"));
		
		ModelAndView mv = new ModelAndView("Word");
		return mv;
	}
	@RequestMapping("/save")
	public void saveFile(HttpServletRequest request, HttpServletResponse response){
		FileSaver fs = new FileSaver(request, response);
		fs.saveToFile("d:\\" + fs.getFileName());
		fs.close();
	}	
	/**
	 * 添加PageOffice的服务器端授权程序Servlet(必须)
	 * @return
	 */
	@Bean
    public ServletRegistrationBean servletRegistrationBean8() {
		com.zhuozhengsoft.pageoffice.poserver.Server poserver = new com.zhuozhengsoft.pageoffice.poserver.Server();
		poserver.setSysPath(poSysPath);//设置PageOffice注册成功后,license.lic文件存放的目录
		ServletRegistrationBean srb = new ServletRegistrationBean(poserver);
		srb.addUrlMappings("/poserver.zz");
		srb.addUrlMappings("/posetup.exe");
		srb.addUrlMappings("/pageoffice.js");
		srb.addUrlMappings("/jquery.min.js");
		srb.addUrlMappings("/pobstyle.css");
		srb.addUrlMappings("/sealsetup.exe");
        return srb;// 
    }
	/**
	 * 添加印章管理程序Servlet(可选)
	 * @return
	 */
	@Bean
    public ServletRegistrationBean servletRegistrationBean9() {
		com.zhuozhengsoft.pageoffice.poserver.AdminSeal adminSeal = new com.zhuozhengsoft.pageoffice.poserver.AdminSeal();
		adminSeal.setAdminPassword(poPassWord);//设置印章管理员admin的登录密码
		adminSeal.setSysPath(poSysPath);//设置印章数据库文件poseal.db存放的目录
		ServletRegistrationBean srb = new ServletRegistrationBean(adminSeal);
		srb.addUrlMappings("/adminseal.zz");
		srb.addUrlMappings("/sealimage.zz");
		srb.addUrlMappings("/loginseal.zz");
        return srb;// 
    }		
}

你可能感兴趣的:(java)