将Ueditor整合到ssh框架
来源:互联网 发布:网络设计师卡通图片 编辑:程序博客网 时间:2024/06/11 09:16
前几天因为所做项目要用到Ueditor,所以就研究了下ueditor,我先用servlet做了下测试发现可以用,包括文件上传,图片上传、管理等,具体代码请看链接Ueditor,
因而我就直接将其加到我ssh的项目里,但是发现老是出错(一个红色的叉),当我调试代码时发现,request里的东西都被struts2过滤掉了,因而老是出错,于是我打算重写过滤器,
为了能够兼容struts2,我直接找到默认的过滤器文件直接复制、粘贴,然后加入我个人的代码,以下是我过滤器的文件内容:
/* * $Id: DefaultActionSupport.java 651946 2008-04-27 13:41:38Z apetrelli $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * 本文件使用struts2默认的拦截器,但增加了个人所需的文件 * */package com.physics.tools.editor;import org.apache.struts2.StrutsStatics;import org.apache.struts2.dispatcher.Dispatcher;import org.apache.struts2.dispatcher.mapper.ActionMapping;import org.apache.struts2.dispatcher.ng.ExecuteOperations;import org.apache.struts2.dispatcher.ng.InitOperations;import org.apache.struts2.dispatcher.ng.PrepareOperations;import org.apache.struts2.dispatcher.ng.filter.FilterHostConfig;import javax.servlet.*;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.util.List;import java.util.regex.Pattern;public class PhysicsFilter implements StrutsStatics, Filter { protected PrepareOperations prepare; protected ExecuteOperations execute;protected List<Pattern> excludedPatterns = null; public void init(FilterConfig filterConfig) throws ServletException { InitOperations init = new InitOperations(); try { FilterHostConfig config = new FilterHostConfig(filterConfig); init.initLogging(config); Dispatcher dispatcher = init.initDispatcher(config); init.initStaticContentLoader(config, dispatcher); prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher); execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);this.excludedPatterns = init.buildExcludedPatternsList(dispatcher); postInit(dispatcher, filterConfig); } finally { init.cleanup(); } } /** * Callback for post initialization */ protected void postInit(Dispatcher dispatcher, FilterConfig filterConfig) { } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String url = request.getRequestURI(); try { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if (( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns))||url.endsWith(".wms")) {chain.doFilter(request, response);} else {request = prepare.wrapRequest(request);ActionMapping mapping = prepare.findActionMapping(request, response, true);if (mapping == null) {boolean handled = execute.executeStaticResourceRequest(request, response);if (!handled) {chain.doFilter(request, response);}} else {execute.executeAction(request, response, mapping);}} } finally { prepare.cleanupRequest(request); } } public void destroy() { prepare.cleanupDispatcher(); }}
其中url.endsWith(".wms")是我不要过滤的url,直接回应。
- 将Ueditor整合到ssh框架
- Ueditor上传图片,ssh和ssm框架下Ueditor整合
- 整合UEditor,SSH下
- UEditor (JSP 1.4.3版本) 集成到ssh框架中
- UEditor (JSP 1.4.3版本) 集成到ssh框架中
- SSH框架整合笔记
- ssh框架整合
- SSH框架整合
- SSH+DWR 框架 整合
- SSH框架整合步骤
- SSH框架的整合
- SSH框架整合步骤
- SSH框架整合步骤
- SSH框架整合步骤
- SSH框架整合步骤
- ssh框架整合详解
- ssh框架整合流程
- ssh框架的整合
- CLRver -- 查看什么程序是用CLR写的
- bps,Bps,pps 区别
- Myeclipse配置Spket的方法
- 《tiny6410裸机程序》第四章:汇编与C混合编程
- Java之Stack --- 栈
- 将Ueditor整合到ssh框架
- 记录 异步请求机制
- ORACLE学习笔记(二)——数据库启动(mount)
- python中os模块用法
- 关于DMA
- ubuntu与xp共享文件夹方式下的文件复制脚本
- WPF中INotifyPropertyChanged用法与数据绑定
- Eclipse中10个最有用的快捷键组合
- 【实验】ARM系统结构实验之Arm分支指令