В проекте нам нужно сделать несколько аватаров загрузку, функции резания изображений, ОК прочитайте следующую статью!
Мне нужен плагин -ин: jquery jcrop
Back -Fend Code:
Пакет org.csg.upload; .imageio.imageio; PARAM PATH2 Путь, хранящийся после резки* @param xx wasf* @param yy ware* @param w* @param h*/ public static void cutimage (String path1, String Path2, Int x, int y, int w, int h) {FileInputStream fileInputStream = null; "JPG"); ).; ("Отказ разрезания");} наконец {try (file inputstream! = Null) {fileInputStream.close ();} if (is! = Null) {iis.close ();}} catch (ioExcation e) {e. printStackTrace ();}}}}}}}}}}}}}}
Код доступа:
<%@page language = "java" import = "java.util.*, org.csg.upload.*" pageencoding = "utf-8"%> <%// Строка относительного пути (er "imgpath") ; Сервер после резки строки PATH2 = RELPATH+"/Images/"+newFilename; Integer.parseint (request.getParameter ("w"); int h = integer.parseint (request.getParameter ("h"); try {upload.c.c utimage (path1, path2, x, y, w, h); .print ("<img src = 'Images/"+newfilename+"'/>");} Catch (Exception e) {e.printstacktrace ();
Код JSP:
<%@ page language = "java" image = "java.util.*" pageencoding = "utf-8"%> <! Jsp Разработайте аватар резание </title> <meta http-equiv = "pragma" content = "no-cache"> <meta http-equiv = "cache-control" content = "no-cache"> <meta http-equiv = «истекает» content = "0"> <meta http-equiv = "keywords" content = "Keyword1, Keyword2, Keyword3"> <Meta http-equiv = "Описание ption" Content = "Это моя страница"> <ссылка rel = "styleSheet" href = "css/jquery.jcrop.css" type = "text/css"/> <script type = "text/javascript" src = "js/jquery.min.js"> </script> <script type = "text/javascript" src = "js/jquery.jcrop.min.js"> </script> <ally type = "text/css"> *{margin: 0; {Margine-top: 20px;} #Preview Pane {Display: Block; 0,. ); } </style> <script type = "text/javascript"> nction () {var jcrop_api, boundx = "", bondy = "", $ preview = $ ('#preview-pane'), $ pcnt = $ ( #Preview-pane .preview-container '), $ pimg = $ ('#preview-pane. #cutimage ') (Jcrop_api.ui.holder);}); $ (#Y1 »). ; Math.round (rx * cx) + 'px', margintop: ' + math.round (ry * cy) +' px '});}}}); > Джава разработка QQ System Rutger </H1> <img id = "cutimage" src = "Images/1.jpg"> <div id = "preview-pane"> <viv> <img src = "Images/1. jpg "/> </div> </div> </div> <form action =" success.jsp "method =" post "> <input type =" text "value =" images/1.jpg "name =" Imgpath "> x axis: <input type =" text "size =" 4 "id =" x1 "name =" x " /> y axis: <input type =" text "size =" 4 "id =" y1 " name = "y"/> width: <input type = "text" size = "4" id = "w" name = "w"/> height: <input type = "text" size = "4" id = " h "name =" h "/> <input type =" Отправить "value =" cut "/> </form> </body> </html>
Карта эффекта:
Выше всего содержимое этой статьи.