步骤 2 : 调用CategoryServlet.update()方法
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
public String update(HttpServletRequest request, HttpServletResponse response, Page page) {
Map<String,String> params = new HashMap<>();
InputStream is = super.parseUpload(request, params);
System.out.println(params);
String name= params.get("name");
int id = Integer.parseInt(params.get("id"));
Category c = new Category();
c.setId(id);
c.setName(name);
categoryDAO.update(c);
File imageFolder= new File(request.getSession().getServletContext().getRealPath("img/category"));
File file = new File(imageFolder,c.getId()+".jpg");
file.getParentFile().mkdirs();
try {
if(null!=is && 0!=is.available()){
try(FileOutputStream fos = new FileOutputStream(file)){
byte b[] = new byte[1024 * 1024];
int length = 0;
while (-1 != (length = is.read(b))) {
fos.write(b, 0, length);
}
fos.flush();
//閫氳繃濡備笅浠g爜锛屾妸鏂囦欢淇濆瓨涓簀pg鏍煎紡
BufferedImage img = ImageUtil.change2jpg(file);
ImageIO.write(img, "jpg", file);
}
catch(Exception e){
e.printStackTrace();
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "@admin_category_list";
}
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|