zoukankan      html  css  js  c++  java
  • 若依框架遇到的问题 和 一些与框架无关的问题。

    报错:使用linux的数据库。找不到某个表,但是数据库里表是存在的。     原因: linux是大小写敏感的

    使用富文本: 浏览器缓存问题,导致不能上传

      1、导入静态资源

      2、在页面使用

                <div class="form-group">
                    <!-- 加载编辑器的容器 -->
                    <script id="editor" name="replyContent" type="text/plain">
                    这里写你的初始化内容
                    </script>
                </div>
    
                <!--ueditor的配置文件-->
                <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.config.js}"></script>
                <!--ueditor编辑器源码文件-->
                <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.all.js}"></script>
    
                <!-- 实例化编辑器 -->
                <script type="text/javascript">
                    var x = window.rootPath;
                    var ue = UE.getEditor('editor');
                    ue.addListener("ready", function () {
                        // editor准备好之后才可以使用
                        // ue.setContent(content);
                        var replyContent = $("#replyContentDTO").val();
                        console.info(replyContent);
                        ue.setContent(replyContent);
                    });
                </script>
    View Code

      3、UeditorController文件

    package com.bravo.cms.controller;
    
    import com.bravo.cms.model.PublicMsg;
    import com.bravo.cms.model.Ueditor;
    import com.bravo.common.config.Global;
    import com.bravo.common.config.ServerConfig;
    import com.bravo.common.core.domain.AjaxResult;
    import com.bravo.common.utils.file.FileUploadUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.multipart.MultipartFile;
    
    import javax.servlet.http.HttpServletRequest;
    
    //import io.swagger.annotations.Api;
    
    @Controller
    //@Api(value = "百度编辑器")
    @RequestMapping("UeditorController")
    public class UeditorController {
    //    @Autowired
    //    private UeditorService ueditorService;
    
        @Autowired
        private ServerConfig serverConfig;
    
        @RequestMapping("ueditor")
        @ResponseBody
        public Object ueditor(HttpServletRequest request, String action, MultipartFile upfile) {
            System.out.println("action:"+action);
            if("config".equals(action)) {
                  return PublicMsg.UEDITOR_CONFIG;
            }
            if ("uploadimage".equals(action) || "uploadfile".equals(action) || "uploadvideo".equals(action)) {//图片上传
                try
                {
                    // 上传文件路径
                    String filePath = Global.getUploadPath();
                    // 上传并返回新文件名称
                    String fileName = FileUploadUtils.upload(filePath, upfile);
                    String url = serverConfig.getUrl() + fileName;
                    Ueditor ueditor = new Ueditor("SUCCESS", url, "ssss", "");
    //                AjaxResult ajax = AjaxResult.success();
    //                ajax.put("fileName", fileName);
    //                ajax.put("url", url);
                    return ueditor;
                }
                catch (Exception e)
                {
                    return AjaxResult.error(e.getMessage());
                }
            }
    
    //        if ("uploadfile".equals(action)) {//文件上传
    //
    //
    //        }
            return PublicMsg.UeditorMsg.ERROR.get();
        }
    
    //    @RequestMapping(value="/imgUpload")
    //    @ResponseBody
    //    public Ueditor imgUpload(MultipartFile upfile) {
    //        Ueditor ueditor = new Ueditor();
    //        return ueditor;
    //    }
    
    
    
    //
    //    public String updateAvatar(MultipartFile file)
    //    {
    //        try
    //        {
    //            if (!file.isEmpty())
    //            {
    //                //插入文件存储表
    //                String id=sysDatasService.insertSelective(file);
    //                if(id!=null){
    //                     return id;
    //                }
    //            }
    //            return null;
    //        }
    //        catch (Exception e)
    //        {
    //            return null;
    //        }
    //    }
    
    
    }
    UeditorController

      4、添加lib包

     富文本部署时,上传文件

    Tomcat关闭报错

    Using CATALINA_BASE:   /home/yang8686/tomcat8686/apache-tomcat-8.5.55
    Using CATALINA_HOME:   /home/yang8686/tomcat8686/apache-tomcat-8.5.55
    Using CATALINA_TMPDIR: /home/yang8686/tomcat8686/apache-tomcat-8.5.55/temp
    Using JRE_HOME:        /usr
    Using CLASSPATH:       /home/yang8686/tomcat8686/apache-tomcat-8.5.55/bin/bootstrap.jar:/home/yang8686/tomcat8686/apache-tomcat-8.5.55/bin/tomcat-juli.jar
    六月 12, 2020 12:34:54 下午 org.apache.catalina.startup.Catalina stopServer
    严重: Could not contact [localhost:8607]. Tomcat may not be running.
    六月 12, 2020 12:34:54 下午 org.apache.catalina.startup.Catalina stopServer
    严重: Catalina.stop: 
    java.net.ConnectException: 拒绝连接 (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at java.net.Socket.connect(Socket.java:556)
        at java.net.Socket.<init>(Socket.java:452)
        at java.net.Socket.<init>(Socket.java:229)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:504)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:389)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:479)
    报错内容

      找到Tomcat端口的进程pid :    lsof -i :8686     kill 找的的线程pid

      原因:未知

    修改jar的路径:

     /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre/lib/security

    部署后,无法下载模板在本地却可以下载模板

      解决的方式:

        打开tomcat,查看 catalina.out 日志文件,发现报以下错误

    12:45:32.622 [http-bio-28080-exec-7] ERROR c.b.w.c.c.CommonController - [fileDownload,65] - 下载文件失败
    java.lang.Exception: 文件名称(e38f3254-e257-49eb-99d4-acb8ffe7e47e_用户上线门店数数据.xlsx)非法,不允许下载。 

      初步判断是乱码问题,将乱码恢复,发现iso-8859-1编码,搜索关键字: tomcat iso-8859-1 乱码 。查看下载模板代码,发现Java里边是一个get请求,使用中文名,由于tomcat get请求乱码 ,导致系统发现文件名非法

      解决: 在tomcat server.xml修改tomcat配置,添加 URIEncoding="UTF-8"

        <Connector port="28080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" URIEncoding="UTF-8" />
    tomcat配置

    LuckyFrame部署war包:方式 https://how2j.cn/k/springboot/springboot-war/1655.html#nowhere     遇到问题解决  https://github.com/pagehelper/pagehelper-spring-boot/issues/18

      以链接一的方式部署,遇到问题,说引入多个分页,在启动类排除分页 @SpringBootApplication(exclude = PageHelperAutoConfiguration.class)

     多环境配置

      1、在主pom添加如下。其中 plugins 标签与里边的内容去掉

        <!--配置环境的profile-->
        <profiles>
            <!--dev默认激活,使用idea Spring Boot 配置启动工程,需要dev的配置-->
            <!--开发环境-->
            <profile>
                <id>dev</id>
                <properties>
                    <profileActive>dev</profileActive>
                </properties>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
            </profile>
            <!--测试环境-->
            <profile>
                <id>test</id>
                <properties>
                    <profileActive>test</profileActive>
                </properties>
            </profile>
            <!--生产环境-->
            <profile>
                <id>prod</id>
                <properties>
                    <profileActive>prod</profileActive>
                </properties>
            </profile>
        </profiles>
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <!--先排除所有的配置文件-->
                    <excludes>
                        <exclude>application*.yml</exclude>
                    </excludes>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <!--引入所需环境的配置文件-->
                    <filtering>true</filtering>
                    <includes>
                        <include>application.yml</include>
                        <include>application-${profileActive}.yml</include>
                    </includes>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    bravo.pom

      2、yml指定到配置文件的变量

      profiles: 
        #active: druid
        active: @profileActive@

      3、刷新maven,可以看到 Profile 可以选择

    th:selected不起作用: 加()

    th:selected="(${parentsType.parentsTypeId == childType.parentsTypeId})"

     数据权限

      自定义时的SQL

    AND (d.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = 102 ) )

      本部门

    AND (d.dept_id = 325980445 )

      本人

    AND (1=0 )

  • 相关阅读:
    210
    209
    208
    207
    定时任务crontab
    Python的zip与*zip函数的应用
    Python的reduce函数与map函数
    解析:cpu与io密集在何场景适合使用多进程,多线程,协程
    Python上下文(转载)
    C10K与C10M的问题
  • 原文地址:https://www.cnblogs.com/Lemonades/p/13069844.html
Copyright © 2011-2022 走看看