반응형

Framework 73

[Spring Security] rememberMe 설정

Spring Security가 제공하는 Remember Me는 시스템이 사용자를 기억하고 세션이 만료된 후 자동으로 로그인해준다. 해시를 사용해 쿠키 기반의 토큰의 보안을 유지하거나 데이터베이스 또는 다른 영구 저장 메커니즘을 사용한다. .and() .logout().deleteCookies("JSESSIONID") .and() .rememberMe().key("uniqueAndSecret").tokenValiditySeconds(86400); configure 메소드에 추가해주었다. 기본 만료 기간은 2주지만, tokenValiditySeconds 메소드로 만료 기간을 하루로 설정했다. Remember Me 쿠키는 username, expirationTime, MD5hash를 담고있다. MD5 hash..

[Error] Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported Form을 submit으로 서버에 요청을 보내면서 발생한 에러다. 이전에는 AJAX로 요청을 보내서 @RequestBody가 컨트롤러에서 있었다. 하지만, submit으로 요청을 보내게 되면 @RequestBody가 필요없고 위와 같은 에러가 생긴다. 더이상 쓸모없는 @RequestBody를 없애면 에러가 해결된다. 👇 참고 https://stackoverflow.com/questions/33796218/content-type-application-x-www-form-urlencodedcharset-utf-8-not-supported-for Content type 'a..

업로드 파일 사이즈

org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes. 이미지 파일 하나 업로드하니까 다음과 같은 에러 발생 기본값이 1048576 bytes 🌿 해결 spring.servlet.multipart.max-file-size=5MB spring.servlet.multipart.max-request-size=10MB build.gradle에 추가하자. max-file-size는 허용 가능한 최대 바이트 사이즈다. 업로드한 파일 중에서 max-file-size를 초과하는 파일이 있다면, IllegalStateEx..

[Error] Could not write JSON: Java 8 date/time type `java.time.LocalDateTime` not supported by default:

There was an unexpected error (type=Internal Server Error, status=500). Could not write JSON: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: java.util.ArrayList[0]->Bulletin.Board.domain.posts.Post["createdDate"]); nested exception is com.fasterxml.jackson.d..

[Error] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer'

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to c..

[Error] java.lang.IllegalStateException: Failed to load ApplicationContext

java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodErr..

[Error] org.springframework.data.redis.serializer.SerializationException

org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: Bulletin.Board.domain.posts.Post Caused by: org.springframework.core.serializer.support.SerializationFailedExcepti..

전체 게시글 목록에서 각 게시글의 댓글 수 출력

전체 게시글 목록에서 각 게시글 제목 옆에 총 댓글 수를 출력한다. 첫 번째 시도) 👉 실패 comments An error happened during template parsing (template: "class path resource [templates/post/postList.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/post/postList.html]") Caused by: org.attoparser.ParseException: Exception evaluating SpringEL ex..

댓글 최신순 정렬

첫 번째 방법) @OneToMany(mappedBy="post", fetch=FetchType.EAGER, cascade=CascadeType.REMOVE) @OrderBy("id desc") private List comment; 댓글 Comment과 M:1 관계를 맺는 Post에 @OrderBy 어노테이션 추가 Comment의 id 필드를 기준으로 내림차순한다. List comments = postRepository.findById(postId).orElseThrow(() -> new PostNotFoundException(postId)).getComment(); Post에서 comment를 가져온다. 두 번째 방법) public List getCommentList(Long postId){ List ..

반응형