Super Large text mix editor Struts2 + FCKeditor-2.3 download can be deployed and used, complete Demo, do not understand can leave a message.

Source: Internet
Author: User

Super Large text mix editor Struts2 + FCKeditor-2.3 download can be deployed and used, complete Demo, do not understand can leave a message.

Original Text: super large text mixed editor Struts2 + FCKeditor-2.3 download can be deployed and used, complete Demo, do not understand can leave a message.

 

Super Large text mix editor Struts2 + FCKeditor-2.3 download can be deployed and used, complete Demo, do not understand can leave a message. 1. the text editor is divided into: Basic, Default var editor = new FCKeditor (content, 800,400, Default,); 2. change the skin and find/EditWebTest/WebRoot/fckeditor/fckconfig. js finds FCKConfig in 45 rows. skinPath = FCKConfig. basePath + 'Skins/default/'; modify the default word. There are three types of skin: default, office2003, and silver.

Package com. zuidaima. edit. util; import java. io. file; import java. io. IOException; import java. io. printWriter; import java. text. simpleDateFormat; import java. util. date; import java. util. list; import javax. servlet. servletException; import javax. servlet. http. httpServlet; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; import net. fckeditor. handlers. commandHandler; import Net. fckeditor. handlers. connectorHandler; import net. fckeditor. handlers. extensionsHandler; import net. fckeditor. handlers. requestCycleHandler; import net. fckeditor. handlers. resourceTypeHandler; import net. fckeditor. response. uploadResponse; import net. fckeditor. response. xmlResponse; import net. fckeditor. tool. utils; import net. fckeditor. tool. utilsFile; import net. fckeditor. tool. utilsResponse; import org. apach E. commons. fileupload. fileItem; import org. apache. commons. fileupload. disk. diskFileItemFactory; import org. apache. commons. fileupload. servlet. servletFileUpload; import org. apache. commons. io. filenameUtils; import org. slf4j. logger; import org. slf4j. loggerFactory;/*** @ author www.zuidaima.com ***/public class MyConnectorServlet extends HttpServlet {private static final long serialVersionUID = 0xb05049436ea5f077 L; private static final Logger logger = LoggerFactory. getLogger (MyConnectorServlet. class); public MyConnectorServlet () {} public void init () throws ServletException, IllegalArgumentException {String s = getServletContext (). getRealPath (ConnectorHandler. getdefauseruserfilespath (); File file = new File (s); UtilsFile. checkDirAndCreate (file); logger.info (MyConnectorServlet successfully initialized !);} Public void doGet (HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException {logger. debug (Entering MyConnectorServlet # doGet); httpservletresponse. setCharacterEncoding (UTF-8); httpservletresponse. setContentType (application/xml; charset = UTF-8); httpservletresponse. setHeader (Cache-Control, no-cache); PrintWriter printwriter = httpservletresponse. get Writer (); String s = httpservletrequest. getParameter (Command); String s1 = httpservletrequest. getParameter (Type); String s2 = httpservletrequest. getParameter (CurrentFolder); logger. debug (Parameter Command :{}, s); logger. debug (Parameter Type :{}, s1); logger. debug (Parameter CurrentFolder :{}, s2); XmlResponse xmlresponse; if (! RequestCycleHandler. isEnabledForFileBrowsing (httpservletrequest) xmlresponse = new XmlResponse (1, The current user isn't authorized for file browsing !); Else if (! CommandHandler. isValidForGet (s) xmlresponse = new XmlResponse (1, Invalid command specified); else if (s1! = Null &&! ResourceTypeHandler. isValid (s1) xmlresponse = new XmlResponse (1, Invalid resource type specified); else if (! UtilsFile. isValidPath (s2) {xmlresponse = new XmlResponse (1, Invalid current folder specified);} else {CommandHandler commandhandler = CommandHandler. getCommand (s); ResourceTypeHandler resourcetypehandler = ResourceTypeHandler. getDefaultResourceType (s1); String s3 = UtilsFile. constructServerSidePath (httpservletrequest, resourcetypehandler); // s3 = s3 +/+ getDate (3); // String s4 = getServletContex T (). getRealPath (s3); File file = new File (s4); UtilsFile. checkDirAndCreate (file); File file1 = new File (file, s2); if (! File1.exists () {xmlresponse = new XmlResponse (102);} else {xmlresponse = new XmlResponse (commandhandler, resourcetypehandler, s2, UtilsResponse. constructResponseUrl (httpservletrequest, resourcetypehandler, s2, true, ConnectorHandler. isFullUrl (); if (commandhandler. equals (CommandHandler. GET_FOLDERS) xmlresponse. setFolders (file1); else if (commandhandler. equals (CommandHandler. GET_FOLDERS_AND_FILES) xmlr Esponse. setFoldersAndFiles (file1); else if (commandhandler. equals (CommandHandler. CREATE_FOLDER) {String s5 = UtilsFile. sanitizeFolderName (httpservletrequest. getParameter (NewFolderName); logger. debug (Parameter NewFolderName :{}, s5); File file2 = new File (file1, s5); byte byte0 = 110; if (file2.exists () byte0 = 101; elsetry {byte0 = (byte) (file2.mkdir ()? 0: 102);} catch (SecurityException securityexception) {byte0 = 103;} xmlresponse. setError (byte0) ;}} printwriter. print (xmlresponse); printwriter. flush (); printwriter. close (); logger. debug (Exiting MyConnectorServlet # doGet);} @ resolve (unchecked) public void doPost (HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException {logger. debug (Ente Ring Connector # doPost); httpservletresponse. setCharacterEncoding (UTF-8); httpservletresponse. setContentType (text/html; charset = UTF-8); httpservletresponse. setHeader (Cache-Control, no-cache); PrintWriter printwriter = httpservletresponse. getWriter (); String s = httpservletrequest. getParameter (Command); String s1 = httpservletrequest. getParameter (Type); String s2 = httpservletrequest. getParameter (CurrentFo Lder); logger. debug (Parameter Command :{}, s); logger. debug (Parameter Type :{}, s1); logger. debug (Parameter CurrentFolder :{}, s2); if (Utils. isEmpty (s) & Utils. isEmpty (s2) {s = QuickUpload; s2 = //;} UploadResponse uploadresponse; if (! RequestCycleHandler. isEnabledForFileUpload (httpservletrequest) uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (203), null, null, The current user isn't authorized for file upload! }); Else if (! CommandHandler. isValidForPost (s) uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (1), null, null, Invalid command specified}); else if (s1! = Null &&! ResourceTypeHandler. isValid (s1) uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (1), null, null, Invalid resource type specified}); else if (! UtilsFile. isValidPath (s2) {uploadresponse = UploadResponse. UR_INVALID_CURRENT_FOLDER;} else {ResourceTypeHandler resourcetypehandler = ResourceTypeHandler. getDefaultResourceType (s1); String s3 = UtilsFile. constructServerSidePath (httpservletrequest, resourcetypehandler); s3 = s3 ++ getDate (3); String s4 = getServletContext (). getRealPath (s3); File file = new File (s4); UtilsFile. checkDirAndCreate (file ); File file1 = new File (file, s2); if (! File1.exists () {uploadresponse = UploadResponse. UR_INVALID_CURRENT_FOLDER;} else {String s5 = null; DiskFileItemFactory diskfileitemfactory = new DiskFileItemFactory (); ServletFileUpload servletfileupload = new ServletFileUpload (diskfileitemfactory); servletfileupload. setHeaderEncoding (UTF-8); try {List list = servletfileupload. parseRequest (httpservletrequest); FileItem fileitem = (FileItem) list. get (0 ); String s6 = UtilsFile. sanitizeFileName (fileitem. getName (); String s7 = FilenameUtils. getName (s6); String s8 = getDate (0); String s9 = FilenameUtils. getExtension (s7); s7 = s8.concat (.). concat (s9.toLowerCase (); if (! ExtensionsHandler. isAllowed (resourcetypehandler, s9) {uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (202)});} else {File file2 = new File (file1, s7); for (int I = 1; file2.exists (); I ++) {s5 = s8.concat (_). concat (String. valueOf (I )). concat (.). concat (s9.toLowerCase (); file2 = new File (file1, s5);} if (Utils. isEmpty (s5) {s2 = s2 + getDate (3) +/; uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (0), UtilsResponse. constructResponseUrl (httpservletrequest, resourcetypehandler, s2, true, ConnectorHandler. isFullUrl ()). concat (s7)}); String aa = UtilsResponse. constructResponseUrl (httpservletrequest, resourcetypehandler, s2, true, ConnectorHandler. isFullUrl ()). concat (s7);} else {uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (201), UtilsResponse. constructResponseUrl (httpservletrequest, resourcetypehandler, s2, true, ConnectorHandler. isFullUrl ()). concat (s5), s5});} if (resourcetypehandler. equals (ResourceTypeHandler. IMAGE) & ConnectorHandler. isSecureImageUploads () {if (UtilsFile. isImage (fileitem. getInputStream () {fileitem. write (file2);} else {fileitem. delete (); uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (202)}) ;}} else {fileitem. write (file2) ;}} catch (Exception exception) {uploadresponse = new UploadResponse (new Object [] {Integer. valueOf (203)}) ;}} printwriter. print (uploadresponse); printwriter. flush (); printwriter. close (); logger. debug (Exiting Connector # doPost);} public static final String getDate (int I) {String as [] = {values, yyyyMMddHHmmss, yyMMddHHmmss, yyyyMMdd, yyyy-MM-dd, HHmmssSSS, HHmmss}; SimpleDateFormat simpledateformat = null; try {simpledateformat = new SimpleDateFormat (as [I]);} catch (Exception exception) {exception. printStackTrace (); System. out. print (exception. toString (); return exception. toString ();} return simpledateformat. format (new Date ());}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.