728x90

개발관련/JAVA 3

[JAVA] html에서 img 태그 src 이미지 URL 추출(Pattern 정규식 사용)

1. 문제상황제휴사와 전문 개발 중 상품 상세페이지의 이미지를 전달 해달라는 요건 전달 받음데이터 확인 결과 상품 상세 페이지의 이미지를 따로 저장하지 않고 html을 통째로 저장전문 전달을 위해 html에서 이미지 url을 추출 해 전달 해야 하는 상황 발생 2.해결 방안Pattern 정규식을 사용 해 img 태그의 src 속성값을 추출한다.핵심 코드 Pattern pattern = Pattern.compile("]*src=\"([^\"]*)\""); Matcher matcher = pattern.matcher(input); public static void main(String[] args) { String detailImg = "\n\n\n"; List imageUrl..

개발관련/JAVA 2025.03.26

[Spring Error] cvc-complex-type.2.3: Element 'beans' cannot have character [children]

에러 내용 Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'beans' cannot have character [children], because the type's content type is element-only. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[xercesImpl-2.9.1.jar:na] at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) ~[xercesImpl-2.9.1.jar:na] at org.apache.xerces...

개발관련/JAVA 2023.04.21

[JAVA] 문자열 byte 확인, byte 단위로 자르기

public class testPjt { public static void main(String[] args) { String str = "가나다라마바사아자차 1111"; int cutBytes = 30; String result = new String(str.getBytes(), 0, cutBytes); System.out.println(result); } } 문자열 길이를 byte 단위로 가져오는 코드. UTF-8 기준 한글 3Byte, 알파벳, 숫자, 띄어쓰기 1Byte public class testPjt { public static void main(String[] args) { String errorMsg = "가나다라마바사아자차"; int byteLen = errorMsg.getBytes()..

개발관련/JAVA 2022.08.03
728x90