细节1
spring.http.encoding.charset=UTF-8 |
细节2
path1=C:/springTemp
|
细节3 <input type="file" @change="getfile($event)">
var app = new Vue({ |
细节4代码
@Value("${path1}") |
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:c:/Temp
<input type="file" name="file1" id="file1" class="form-control" @change="getfiles($event)">
var upapp=new Vue({
el:"#upapp",
data:{
files:[],
},
methods:{
getfiles:function(event){
this.files= event.target.files; //通过点击文件上传时间获得文件
},
ajaxsubmit:function(){
let fdate=new FormData();
fdate.append("files",this.files[0]);
$.ajax({
url: "ajaxupload",
type: 'POST',
cache: false,
data: fdate,
processData: false, //文件上传
contentType: false,
dataType:"json", //回调类型
beforeSend: function(){
upapp.up_mess = "文件上传中..";
},
success : function(json) {
if (json.code==200) {
upapp.up_mess = "文件上传完成"
swal("文件上传完成","表扬","success");
myload();
} else if(json.code==1001){
toastr.success(json.message);
}
else {
upapp.error_text = "上传失败了"
}
upapp.error_text=json.message;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
upapp.error_text = "上传失败,文件可能超过文件大小限制"
toastr.error("上传失败,文件可能超过文件大小限制请与老师联系");
},
});
---------------------------------------------------------------------------------------------------------------------------
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
文件上传时
let fdate = new FormData();
for(let f in this.food){
fdate.append(f,this.food[f]);
}
for(let i=0;i<this.files.length;i++){
fdate.append("files",this.files[i]);
}
axios.post("addfoodajax",fdate,{
headers: { 'Content-Type': 'multipart/form-data' }
}).then(function(response){
if(response.data!='null') {
// app.foods.push(response.data);
app.foods.splice(0,0,response.data); //第一个参数是下标,第二个参数是影响的个数,第三个是值
app2.$data.files='';
}
});
高级查询时
axios.get("queryfood",{params:app.food})
.then(function (resp) {
app.foods=resp.data.list;
app.pageInfo=resp.data;
}).catch(function (reason) {
alert("服务器错误"+reason)
})
:class="{'hidden':!pageInfo.hasPreviousPage}"