목록Spring Framework (8)
0gam
Spring Framework provides following ways to help us achieving robust exception handling.Controller Based – We can define exception handler methods in our controller classes. All we need is to annotate these methods with @ExceptionHandler annotation. This annotation takes Exception class as argument. So if we have defined one of these for Exception class, then all the exceptions thrown by our req..
@ComponentScanIf you understand component scan, you understand Spring.Spring is a dependency injection framework. It is all about beans and wiring in dependencies.The first step of defining Spring Beans is by adding the right annotation - @Component or @Service or @Repository.However, Spring does not know about the bean unless it knows where to search for it.This part of “telling Spring where to..
session-registry-alias. It can also be useful to have a reference to the internal session registry for use in your own beans or an admin interface. You can expose the internal bean using the session-registry-alias attribute, giving it a name that you can use elsewhere in your configuration. session-registry-ref. The user can supply their own SessionRegistry implementation using the session-regis..
up votedown voteaccepted@Controller is used to mark classes as Spring MVC Controller.@RestController is a convenience annotation that does nothing more than adding the @Controller and @ResponseBody annotations (see: Javadoc)So the following two controller definitions should do the same@Controller @ResponseBody public class MyController { } @RestController public class MyRestController { }
headers : {Accept : "application/json; charset=utf-8",}, The Request -> contorller( produces = "application/json") ------------------------------------------------------------------------ contentType : 'application/json', The Request -> controller ( consumes = "application/json" ) @Produces 는 Request header Accept, mine type 가 서로 맞을 때@Consumes 는 Request header content-Type 가 서로 맞거나 !로 제외하였을 때
프로젝트 진행중, AJAX를 이용하여 @response List 로 response에 담아 리스트를 사용하려 하였을 때 당했던 일이다. 대충 에러 내용이 List -> 객체 -> 객체 로 이어진 관계를 표현할 수 없다. - 잭슨 맵퍼 라는 것을 보고 검색을 시작하였다. 바로 나오는 결과는 엔티티 관계를 제이슨이 무시하게 해줘라. 였다. 말 그대로 사용하는 List의 객체의 연관관계를 제이슨이 무시할 수 있도록, 해당 엔티티 상단에 @JsonIgnoreProperties(ignoreUnknown = true) ,에러에서 설명해준 객체에 @JsonIgnore(true) 를 설정해주었다. 끝.
Azure Web Service 사용하여 웹 프로젝트를 빌드하니 쿠키를 사용 할 수 없는 것이다. 해서 검색을 하였더니, 초기 Azure 설정을 바꿔줘야 한다는 말이있었다.https://azure.microsoft.com/en-us/blog/disabling-arrs-instance-affinity-in-windows-azure-web-sites/ 따라서 설정을 변경하는 화면을 보니 이미 false로 꺼져있는 상태였고... 계속해서 서치를 하다 그냥 브라우저에 생성되어 있는 쿠키를 삭제하였다.그랬더니, 내가 원했던 나의 language 쿠키가 !! 뙇. 하하하... 그냥 초기에 빌드할 때 애저에서 만들어주는 쿠키를 지우니 해결.
interceptor 사용중에 prehandle() 안의 handle 디버그를 하니 "defaultServletName" 으로 여러 번 실행됐다. 왜 이렇게 반복해서 실행되나 궁금해서 디버그를 해보니 12번 반복되는 것이였다.해서 검색을 해보니 3.0.4 spring 버전부터 UrlRewriteFilter를 제거할 수 있게 됐고, *.do, *.action 등을 왜 사용했는지 를 알게 되면서 이 녀석이 하는 일과 왜 만들어졌는지 알게 되었다. 리소스 파일 갯수만큼 반복해서 실행하는 것이였다.