壹.引进讲个jar包 springmvc设置

配置文件难题

commons-fileupload-1.3.3.jar

近些日子报错音讯:
2016-03-30 12:19:51.968 INFO 4796 — [ main]
o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from
class path resource [front.xml]
2016-03-30 12:19:52.031 WARN 4796 — [ main]
ationConfigEmbeddedWebApplicationContext : Exception encountered during
context initialization – cancelling refresh attempt:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 5 in XML document from class path resource [front.xml] is
invalid; nested exception is org.xml.sax.SAXParseException; lineNumber:
5; columnNumber: 106; 涓庡厓绱犵被鍨? “beans” 鐩稿叧鑱旂殑灞炴??
“xsi:schemaLocation” 鐨勫墠缂? “xsi” 鏈粦瀹氥??
2016-03-30 12:19:52.031 INFO 4796 — [ main]
.b.l.ClasspathLoggingApplicationListener : Application failed to start
with classpath:
[file:/E:/workspace/yycrm/yycrm-collection-web/target/classes/,
file:/G:/maven_jar/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar,
file:/G:/maven_jar/org/codehaus/jettison/jettison/1.2/jettison-1.2.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-web/1.3.0.RELEASE/spring-boot-starter-web-1.3.0.RELEASE.jar,
file:/G:/maven_jar/io/netty/netty/3.7.0.Final/netty-3.7.0.Final.jar,
file:/G:/maven_jar/com/fasterxml/jackson/core/jackson-core/2.6.3/jackson-core-2.6.3.jar,
file:/G:/maven_jar/org/mybatis/mybatis/3.3.0/mybatis-3.3.0.jar,
file:/G:/maven_jar/log4j/log4j/1.2.17/log4j-1.2.17.jar,
file:/G:/maven_jar/org/springframework/spring-tx/4.2.3.RELEASE/spring-tx-4.2.3.RELEASE.jar,
file:/G:/maven_jar/aopalliance/aopalliance/1.0/aopalliance-1.0.jar,
file:/G:/maven_jar/org/springframework/spring-webmvc/4.2.3.RELEASE/spring-webmvc-4.2.3.RELEASE.jar,
file:/G:/maven_jar/com/github/jsqlparser/jsqlparser/0.9.1/jsqlparser-0.9.1.jar,
file:/G:/maven_jar/org/slf4j/log4j-over-slf4j/1.7.13/log4j-over-slf4j-1.7.13.jar,
file:/G:/maven_jar/org/apache/poi/poi-ooxml-schemas/3.12/poi-ooxml-schemas-3.12.jar,
file:/G:/maven_jar/org/eclipse/jdt/core/compiler/ecj/4.4.2/ecj-4.4.2.jar,
file:/G:/maven_jar/com/fasterxml/aalto-xml/0.9.11/aalto-xml-0.9.11.jar,
file:/G:/maven_jar/org/springframework/spring-context-support/4.2.3.RELEASE/spring-context-support-4.2.3.RELEASE.jar,
file:/G:/maven_jar/javax/servlet/jstl/1.2/jstl-1.2.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-logging/1.3.0.RELEASE/spring-boot-starter-logging-1.3.0.RELEASE.jar,
file:/G:/maven_jar/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar,
file:/G:/maven_jar/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar,
file:/G:/maven_jar/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-redis/1.3.0.RELEASE/spring-boot-starter-redis-1.3.0.RELEASE.jar,
file:/G:/maven_jar/org/springframework/batch/spring-batch-infrastructure/3.0.5.RELEASE/spring-batch-infrastructure-3.0.5.RELEASE.jar,
file:/G:/maven_jar/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar,
file:/G:/maven_jar/com/thoughtworks/xstream/xstream/1.4.7/xstream-1.4.7.jar,
file:/G:/maven_永利开户送38元体验金,jar/javax/batch/javax.batch-api/1.0/javax.batch-api-1.0.jar,
file:/G:/maven_jar/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar,
file:/G:/maven_jar/org/springframework/spring-core/4.2.3.RELEASE/spring-core-4.2.3.RELEASE.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-tomcat/1.3.0.RELEASE/spring-boot-starter-tomcat-1.3.0.RELEASE.jar,
file:/G:/maven_jar/org/hibernate/hibernate-validator/5.2.2.Final/hibernate-validator-5.2.2.Final.jar,
file:/G:/maven_jar/com/ibm/jbatch/com.ibm.jbatch-tck-spi/1.0/com.ibm.jbatch-tck-spi-1.0.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-jdbc/1.3.0.RELEASE/spring-boot-starter-jdbc-1.3.0.RELEASE.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-aop/1.3.0.RELEASE/spring-boot-starter-aop-1.3.0.RELEASE.jar,
file:/G:/maven_jar/org/slf4j/jul-to-slf4j/1.7.13/jul-to-slf4j-1.7.13.jar,
file:/G:/maven_jar/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter/1.3.0.RELEASE/spring-boot-starter-1.3.0.RELEASE.jar,
file:/G:/maven_jar/org/apache/httpcomponents/httpclient/4.5.1/httpclient-4.5.1.jar,
file:/G:/maven_jar/org/springframework/spring-beans/4.2.3.RELEASE/spring-beans-4.2.3.RELEASE.jar,
file:/G:/maven_jar/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar,
file:/G:/maven_jar/org/springframework/spring-web/4.2.3.RELEASE/spring-web-4.2.3.RELEASE.jar,
file:/G:/maven_jar/org/apache/poi/poi-ooxml/3.12/poi-ooxml-3.12.jar,
file:/G:/maven_jar/org/mybatis/mybatis-spring/1.2.3/mybatis-spring-1.2.3.jar,
file:/G:/maven_jar/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar,
file:/G:/maven_jar/org/springframework/spring-expression/4.2.3.RELEASE/spring-expression-4.2.3.RELEASE.jar,
file:/G:/maven_jar/org/codehaus/woodstox/stax2-api/4.0.0/stax2-api-4.0.0.jar,
file:/G:/maven_jar/com/101tec/zkclient/0.7/zkclient-0.7.jar,
file:/G:/maven_jar/jline/jline/0.9.94/jline-0.9.94.jar,
file:/G:/maven_jar/org/aspectj/aspectjweaver/1.8.7/aspectjweaver-1.8.7.jar,
file:/G:/maven_jar/com/fasterxml/jackson/dataformat/jackson-dataformat-xml/2.6.3/jackson-dataformat-xml-2.6.3.jar,
file:/G:/maven_jar/mysql/mysql-connector-java/5.1.37/mysql-connector-java-5.1.37.jar,
file:/G:/maven_jar/org/springframework/batch/spring-batch-core/3.0.3.RELEASE/spring-batch-core-3.0.3.RELEASE.jar,
file:/G:/maven_jar/ch/qos/logback/logback-core/1.1.3/logback-core-1.1.3.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-autoconfigure/1.3.0.RELEASE/spring-boot-autoconfigure-1.3.0.RELEASE.jar,
file:/G:/maven_jar/redis/clients/jedis/2.7.3/jedis-2.7.3.jar,
file:/G:/maven_jar/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar,
file:/G:/maven_jar/org/springframework/spring-jdbc/4.2.3.RELEASE/spring-jdbc-4.2.3.RELEASE.jar,
file:/G:/maven_jar/com/hp/crm/yycrm-common-core/1.1.0/yycrm-common-core-1.1.0.jar,
file:/G:/maven_jar/org/apache/zookeeper/zookeeper/3.4.6/zookeeper-3.4.6.jar,
file:/G:/maven_jar/org/springframework/session/spring-session/1.0.2.RELEASE/spring-session-1.0.2.RELEASE.jar,
file:/G:/maven_jar/org/springframework/spring-aop/4.2.3.RELEASE/spring-aop-4.2.3.RELEASE.jar,
file:/G:/maven_jar/commons-codec/commons-codec/1.10/commons-codec-1.10.jar,
file:/G:/maven_jar/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar,
file:/G:/maven_jar/org/apache/tomcat/embed/tomcat-embed-el/8.0.28/tomcat-embed-el-8.0.28.jar,
file:/G:/maven_jar/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot/1.3.0.RELEASE/spring-boot-1.3.0.RELEASE.jar,
file:/G:/maven_jar/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.28/tomcat-embed-logging-juli-8.0.28.jar,
file:/G:/maven_jar/com/zaxxer/HikariCP/2.4.2/HikariCP-2.4.2.jar,
file:/G:/maven_jar/org/apache/tomcat/embed/tomcat-embed-core/8.0.28/tomcat-embed-core-8.0.28.jar,
file:/G:/maven_jar/org/springframework/data/spring-data-redis/1.6.1.RELEASE/spring-data-redis-1.6.1.RELEASE.jar,
file:/G:/maven_jar/com/warrenstrange/googleauth/0.5.0/googleauth-0.5.0.jar,
file:/G:/maven_jar/com/github/pagehelper/pagehelper/4.0.3/pagehelper-4.0.3.jar,
file:/G:/maven_jar/org/slf4j/jcl-over-slf4j/1.7.13/jcl-over-slf4j-1.7.13.jar,
file:/G:/maven_jar/junit/junit/4.12/junit-4.12.jar,
file:/G:/maven_jar/org/springframework/spring-context/4.2.3.RELEASE/spring-context-4.2.3.RELEASE.jar,
file:/G:/maven_jar/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.28/tomcat-embed-websocket-8.0.28.jar,
file:/G:/maven_jar/com/fasterxml/jackson/core/jackson-annotations/2.6.3/jackson-annotations-2.6.3.jar,
file:/G:/maven_jar/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.6.3/jackson-module-jaxb-annotations-2.6.3.jar,
file:/G:/maven_jar/org/springframework/retry/spring-retry/1.1.2.RELEASE/spring-retry-1.1.2.RELEASE.jar,
file:/G:/maven_jar/com/alibaba/dubbo/2.4.10/dubbo-2.4.10.jar,
file:/G:/maven_jar/org/springframework/boot/spring-boot-starter-validation/1.3.0.RELEASE/spring-boot-starter-validation-1.3.0.RELEASE.jar,
file:/G:/maven_jar/com/fasterxml/jackson/core/jackson-databind/2.6.3/jackson-databind-2.6.3.jar,
file:/G:/maven_jar/org/apache/tomcat/embed/tomcat-embed-jasper/8.0.28/tomcat-embed-jasper-8.0.28.jar,
file:/G:/maven_jar/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar,
file:/G:/maven_jar/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar,
file:/G:/maven_jar/stax/stax-api/1.0.1/stax-api-1.0.1.jar]
2016-03-30 12:19:52.046 ERROR 4796 — [ main]
o.s.boot.SpringApplication : Application startup failed

commons-io-2.5.jar

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 5 in XML document from class path resource [front.xml] is
invalid; nested exception is org.xml.sax.SAXParseException; lineNumber:
5; columnNumber: 10陆; 涓庡厓绱犵被鍨? “beans” 鐩稿叧鑱旂殑灞炴??
“xsi:schemaLocation” 鐨勫墠缂? “xsi” 鏈粦瀹氥??

 

    <!-- 定义文件解释器 -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- 设置默认编码 -->
        <property name="defaultEncoding" value="utf-8"></property>
        <!-- 文件大小最大值 -->
        <property name="maxUploadSize" value="10485760000" />
        <!-- 内存中的最大值 -->
        <property name="maxInMemorySize" value="40960" />
    </bean>

 

2.HTML 对file做了css美化 
点击开关能够清空file

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>新增地名标志</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/bootstrap-datetimepicker.css" type="text/css"/>
    <script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.min.js" type="text/javascript"></script>
    <script src="js/bootstrap-datetimepicker.js"></script>
    <script src="js/bootstrap-datetimepicker.zh-CN.js"></script>

    <script src="js/table.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <script src="../../js/jquery.tips.js"></script>
    <script src="js/hint.js"></script>
    <style>
    .readonly{
    background-color: rgb(242, 242, 242);
    }

    /*a  upload */
.a-upload {
    padding: 4px 10px;
    height: 36px;
    line-height: 20px;
    position: relative;
    cursor: pointer;
    color: #888;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    *display: inline;
    *zoom: 1
}

.a-upload  input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
    filter: alpha(opacity=0);
    cursor: pointer
}

.a-upload:hover {
    color: #444;
    background: #eee;
    border-color: #ccc;
    text-decoration: none
}
.close-upimg:hover {
    background-color: blue;
}

    </style>

</head>
<body>
    <form id="dmbz">
        <table class="table table-bordered table-hover">
            <tr>
                <td class="danyuange">标志文件上传</td>
                <td colspan="7">
                    <a href="javascript:;" id="a-upload"class="a-upload" style="float:left;">
                        <input type="file" id='file21' name="zhaopianwenjianming" onchange="showPreview(this)">点击这里上传文件
                    </a> 
                    <div class=fileImgDel style="height:36px;float:left;line-height: 36px;">

                        <img src='../../img/del.png' class='close-upimg' id='close-upimg' onclick="delFile()" style='float:left;position:relative;top:10px;'>
                    </div>
                </td>
            </tr>

        </table>
    </form>

</body>
</html>

<script type="text/javascript">
function showPreview(source) {
    $(".fileImgDel").empty();
    $(".fileImgDel").append(""
    +"<img src='../../img/del.png' class='close-upimg' id='close-upimg' onclick="
    +"delFile()"
    +" style='float:left;position:relative;top:10px;'>");
    var arrs = $(source).val().split('\\'); 
    var filename=arrs[arrs.length-1]; 
    $(".show").text(filename);
}
function delFile(){
    $(".fileImgDel").empty();
    document.getElementById("a-upload").innerHTML="<input type='file' id='file21' name='zhaopianwenjianming' onchange='showPreview(this)'>点击这里上传文件";
     $(".fileImgDel").append(""
    +"<img src='../../img/del.png' class='close-upimg' id='close-upimg' onclick="
    +"delFile()"
    +" style='float:left;position:relative;top:10px;'>");
    //var biaozhidaima=$("#biaozhidaima").val();
}

</script>

3.ajax提交

function placeMark_Save(){
    var ss2,fd;
    if(!!window.ActiveXObject || "ActiveXObject" in window){//判断浏览器是否为IE11
        //alert('是IE!')
        ss2 = $("#dmbz", window.frames['iframe_bz'].document);
    }else{
        //alert('非IE!')
        ss2 = $("#dmbz", window.frames['iframe_bz'].contentDocument);
    }
    //-----------------------------------------------------formdata
    if (action == "add") {
        fd = new FormData(ss2[0]);
        fd.append("id","0");//新增formdata元素
        fd.append("uuid","");
        fd.append("diminguuid",dmInfo.guid);
        fd.append("action","add");
    }else{
        fd = new FormData(ss2[0]);
        fd.append("action","edit");
        fd.append("uuid",uuid_biaozhi);
    }
//ajax提交
     $.ajax({
         url: 'placeName/biaoZhiSave.do',
         type: 'POST',
         datatype: 'json',
         data: fd,
         cache:false,
         traditional: true,
         contentType: false,
         processData: false,
         success : function(data) {
                if (data) {
                    placeMarkTable_Close();// 成功后才能关闭对话框
                    jQuery(placeMark_Table).jqGrid('setGridParam', {
                                url : 'placeName/biaozhiInit.do'
                            }).trigger('reloadGrid');
                } else {
                    $("#markBtn").tips({
                                side : 1,
                                msg : "数据保存失败!",
                                bg : '#FF5080',
                                time : 5
                            });
                }
            }

        });
}

4.Controller.java文件

        @RequestMapping(value = "/biaoZhiSave")
        public void biaoZhiSave(@RequestParam(value = "zhaopianwenjianming", required = false)MultipartFile zhaopianwenjianming,
                HttpServletRequest request,HttpServletResponse response) throws IllegalStateException, IOException{
            String newUuid = "";
            String action = request.getParameter("action");// 操作符
            String fileName=request.getParameter("biaozhidaima");//标志代码---作为文件名

            JSONObject jsonData=new JSONObject();//将传入的数据转为json对象
            Map<String,String[]> paramMap = request.getParameterMap();
            for(String name : paramMap.keySet()) {
            String[] values = paramMap.get(name);
            jsonData.put(name, StringUtils.join(values));
            }
//保存图片
            if (!zhaopianwenjianming.isEmpty()) {//如果有图片
                //保存到服务器WEB-INF\\upload目录下
                String realPath = request.getSession().getServletContext().getRealPath("/WEB-INF/upload");   
                String ext = FilenameUtils.getExtension(zhaopianwenjianming.getOriginalFilename());//文件后缀名
                zhaopianwenjianming.transferTo(new File(realPath+"\\"+ fileName + "." + ext));
                jsonData.put("zhaopianwenjianming",fileName + "." + ext);

                //保存文件到D:\\upload目录下
               /* String ext = FilenameUtils.getExtension(zhaopianwenjianming.getOriginalFilename());//文件后缀名
                zhaopianwenjianming.transferTo(new File("D:\\upload\\" + fileName + "." + ext));
                jsonData.put("zhaopianwenjianming",fileName + "." + ext);*/
            }

        }

 

相关文章