나비BOS가 개발한--사진 업로드 코드
- import com.kingdee.eas.hr.emp.client.PhotoPanel;
- import java.awt.image.BufferedImage;
-
- public class RentVehicleEditUI extends AbstractRentVehicleEditUI {
- private static final Logger logger = CoreUIObject
- .getLogger(RentVehicleEditUI.class);
-
- // number, number
- String tempNumber = "";
-
- // ,
- String tempIdentityNo = "";
-
- PhotoPanel photoPanel = new PhotoPanel();
-
- BufferedImage bufferedImage = null;
-
- /**
- * output class constructor
- */
- public RentVehicleEditUI() throws Exception {
- super();
- }
-
- /**
- * output loadFields method
- */
- public void loadFields() {
- super.loadFields();
- // number ,
- tempNumber = this.editData.getNumber();
- tempIdentityNo = this.editData.getIdentityNo();
- this.initPhotoPanel();//
- if (this.oprtState.equals(OprtState.ADDNEW)) {
- photoPanel.setSelectImage(null);
- photoPanel.repaint();
- } else {
- try {
- this.loadImage();//
- } catch (Exception e) {
- // MsgBox.showWarning(" !");
- e.printStackTrace();
- }
- }
-
- }
-
- //
- private void initPhotoPanel() {
-
- photoPanel.setOprtStat("ADD");
- photoPanel.setBounds(627, 117, 169, 150);
- photoPanel.setBackground(Color.ORANGE);
- this.add(photoPanel);
- }
-
- //
- private void loadImage() throws Exception {
- IRentVehicle irentVehicle = RentVehicleFactory.getRemoteInstance();
- RentVehicleInfo rentVehicleInfo = null;
-
- try {
- rentVehicleInfo = irentVehicle
- .getRentVehicleInfo("select driverPhoto where id =" + "'"
- + this.editData.getId() + "'"); // select
- // DriverPhoto
- } catch (ObjectNotFoundException e) {
- MsgBox.showInfo(" ");
- SysUtil.abort();
- }
- if (!rentVehicleInfo.isEmpty()) {
- byte[] byteArray = rentVehicleInfo.getDriverPhoto();
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- byteArray);
- bufferedImage = ImageIO.read(byteArrayInputStream);
- photoPanel.setSelectImage(bufferedImage);
- byteArrayInputStream.close();
- photoPanel.repaint();
- }
-
- }
-
- //
- public byte[] imageToBytes(File file) {
-
- if (this.oprtState.equals(OprtState.ADDNEW)) {
- // if(file==null){
- // MsgBox.showWarning(" !");
- // }
- }
- if (file != null) {
- int size = (int) file.length();
- FileInputStream fin = null;
- try {
- fin = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- byte[] bts = null;
- if (size > 0) {
- bts = new byte[size];
- try {
- fin.read(bts);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return bts;
- }
- }
- return null;
- }
또한 엔티티에 ByteArray 유형의 속성을 추가합니다.
해당 테이블의 필드 유형은 BLOB입니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
vue 단일 페이지에 여러 개의 echarts 도표가 있을 때의 공용 코드 쓰기html에서: 데이터 처리는 말할 필요가 없다.응, 직접 그림을 그려: 공통 섹션: 이 페이지를 떠날 때 파괴: 추가 정보: Vue + Echarts 차트 표시 및 동적 렌더링 준비 작업 echarts 의존 설치 n...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.