In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces Jquery how to achieve file submission, the article is very detailed, has a certain reference value, interested friends must read it!
First introduce the file jquery.js,jquery.form.js,jqueryMultiFile.js
Add to the JSP page:
$(document) .ready (function () {
('# myfile') .MultiFile ({
Accept:'jpg | png | bmp | gif'
Max:10
STRING: {
Remove:' remove'
Selected:' has chosen: $file'
Sorry, denied:' is not supported: $extents'
Duplicate duplicate:' file:\ nduplicate fileholders'
}
AutoIntercept: ['ajaxForm']
});
}
("# editRoomForm") .ajaxForm ({
Url: "/ smart/zone/updateRoom"
DataType: "json"
Success:function (data) {
If (data =-1) {
}
Error:function () {
}
});
Added in Form
Modification type: enctype= "multipart/form-data"
In Java
@ RequestMapping (value = "/ updateRoom")
@ ResponseBody
Public int updateRoom (@ ModelAttribute ("editRoomForm") MeetingRoomDTO room, String [] editUserGroupSelected
@ RequestParam MultipartFile [] myfile, HttpServletRequest request, HttpSession session) {
Try {
ZoneDTO zone = zoneService.getZoneById (room.getZoneID ())
If (myfile! = null & & myfile.length > 0) {
/ / Image storage path
String path = request.getRealPath ("/") + "resources\\ p_w_picpaths\\ room\\ p_w_picpathName\"
/ / Database storage path
String dbpath = "resources/p_w_picpaths/room/p_w_picpathName/"
/ / Picture name
String p_w_picpathName = ""
String pathName = ""
For (MultipartFile file: myfile) {
String fileName = file.getOriginalFilename ()
Random r = new Random ()
Long Name = System.currentTimeMillis ()
Name = Name + r.nextInt (900000) + 100000
Try {
FileUtils.copyInputStreamToFile (file.getInputStream (), new File (path + zone.getId () + "_")
+ Name + fileName.substring (fileName.indexOf (".")
} catch (IOException e) {
LOGGER.error ("failed to upload live pictures of the conference room" + e)
E.printStackTrace ()
}
P_w_picpathName + = zone.getId () + "_" + fileName + ","
PathName + = dbpath + zone.getId () + "_" + Name + fileName.substring (fileName.indexOf (".") + ","
}
Zone.setNavigationMap (pathName)
Zone.setImageName (p_w_picpathName)
}
If ("" .equals (room.getCapacityStr () {
Room.setCapacity (0)
} else {
Room.setCapacity (Integer.valueOf (room.getCapacityStr ()
}
Room.setAudit (room.getEditAudit ())
Room.setIsValid (0)
Zone.setIsValid (0)
ZoneService.updateMeetingRoom (zone, room, editUserGroupSelected)
Return 1
} catch (ZoneExistException e) {
LOGGER.error ("Conference Room already exists", e)
Return-2
} catch (WSMException e) {
/ / TODO Auto-generated catch block
LOGGER.error ("failed to modify conference room information" + e)
Return-3
}
}
The above is all the contents of the article "how to achieve document submission by Jquery". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.