묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
안녕하세요 강의 잘보고있습니다,.
질문이 하나있습니다.8:48인데요 @PostMapping(SETTINGS_PASSWORD_URL)public String passUpdate(@CurrentUser Account account, @Valid PasswordForm passwordForm, Errors errors,Model model, RedirectAttributes attributes){System.out.println("errors : " + errors);if(errors.hasErrors()){ model.addAttribute(account);return SETTINGS_PASSWORD_URL;} 이부분인데 에러가 났을때 왜 model.addAttribute(account); (66라인)모델이 다시 담아주는건가요 ?? ==================================== 다시 생각해보니 account 객체가 nav-bar 에서 필요해서(account 객체에 따른 이미지 보여주기) 다시 담아주는거 같네요
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
3:34 인증 메일 확인 - 입력값 오류
안녕하세요.아직 앞부분이지만 강의 최고입니다. 질문1테스트코드 인증 메일 확인 - 입력값 오류에 대해서 지금 로직은 이메일 자체가 없으니까 이메일이 없는 오류고 이메일은 존재하나 토큰이 일치 하지않는경우 이렇게 2가지로 테스트 코드를 진행할 필요까진 없는건가요 ? =================================질문25:45 초에는 @Transactional 을 달아주셨는데 이 이유가58 라인에 있는 newAccount.generateEmailCheckToken(); 코드를 영속객체로 관리 해주기 위함 이라고 생각하면 될까요?
-
해결됨스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
th:field 에서 id 가 override 되지 않는 문제
강의 내용을 조금 테스트 하던 중name 과 value 는 input tag 에 미리 정의되어있든 정의되어있지 않든 th:field 에서 의도한 대로 나오지만id 는 미리 정의되어있는경우 field 가 override 하고 있지 않아보입니다. 원래 이런건가요 아님 새로 바뀐건가요?버전은 spring boot, spring-boot-starter-tymeleaf, spring-boot-starter-web 전부 2.4.4 이고 내용대로 미리 전달받은 프로젝트로 실행했습니다.
-
해결됨스프링과 JPA 기반 웹 애플리케이션 개발
12:15와는 다른 화면이 나옵니다.
읽기 쉽게 fragments.html에 있는 코드를 settings.tags.html에 옮겨 적었습니다. 코드 내용<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Study Club</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@yaireo/tagify@3.5.1/dist/tagify.css"> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/jdenticon@3.2.0/dist/jdenticon.min.js" async integrity="sha384-yBhgDqxM50qJV5JPdayci8wCfooqvhFYbIKhv0hTtLvfeeyJMJCscRfFNKIxt43M" crossorigin="anonymous"> </script> <style> .container{ max-width: 100%; } .tagify-outside{ border: 0; padding: 0; margin: 0; } </style> </head> <body class="bg-light"> <nav class="navbar navbar-expand-sm navbar-dark bg-dark"> <a class="navbar-brand" href="/" th:href="@{/}"> <img src="/images/logo_symbol.png" width="30" height="30"> </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <form th:action="@{/search/study}" class="form-inline" method="get"> <input class="form-control mr-sm-2" name="keyword" type="search" placeholder="스터디 찾기" aria-label="Search" /> </form> </li> </ul> <ul class="navbar-nav justify-content-end"> <li class="nav-item" sec:authorize="!isAuthenticated()"> <a class="nav-link" th:href="@{/login}">로그인</a> </li> <li class="nav-item" sec:authorize="!isAuthenticated()"> <a class="nav-link" th:href="@{/sign-up}">가입</a> </li> <li class="nav-item" sec:authorize="isAuthenticated()"> <a class="nav-link" th:href="@{/notifications}"> <i class="fa fa-bell-o"></i> </a> </li> <li class="nav-item" sec:authorize="isAuthenticated()"> <a class="nav-link btn btn-outline-primary" th:href="@{/notifications}"> <i class="fa fa-plus" aria-hidden="true"></i> 스터디 개설 </a> </li> <li class="nav-item dropdown" sec:authorize="isAuthenticated()"> <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <svg th:if="${#strings.isEmpty(account?.profileImage)}" data-jdenticon-value="user127" th:data-jdenticon-value="${#authentication.name}" width="24" height="24" class="rounded border bg-light"></svg> <img th:if="${!#strings.isEmpty(account?.profileImage)}" th:src="${account.profileImage}" width="24" height="24" class="rounded border"/> </a> <div class="dropdown-menu dropdown-menu-sm-right" aria-labelledby="userDropdown"> <h6 class="dropdown-header"> <span sec:authentication="name">Username</span> </h6> <a class="dropdown-item" th:href="@{'/profile/' + ${#authentication.name}}">프로필</a> <a class="dropdown-item" >스터디</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="#" th:href="@{'/settings/profile'}">설정</a> <form class="form-inline my-2 my-lg-0" action="#" th:action="@{/logout}" method="post"> <button class="dropdown-item" type="submit">로그아웃</button> </form> </div> </li> </ul> </div> </nav> <div class="container"> <div class="row mt-5 justify-content-center"> <div class="col-2"> <div class="list-group"> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'profile'}? active" href="#" th:href="@{/settings/profile}">프로필</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'password'}? active" href="#" th:href="@{/settings/password}">비밀번호</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'notifications'}? active" href="#" th:href="@{/settings/notifications}">알림</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'tags'}? active" href="#" th:href="@{/settings/tags}">관심 주제</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'zones'}? active" href="#" th:href="@{/settings/zones}">활동 지역</a> <a class="list-group-item list-group-item-action list-group-item-danger" th:classappend="${currentMenu == 'account'}? active" href="#" th:href="@{/settings/account}">계정</a> </div> </div> <div class="col-8"> <div class="row"> <h2 class="col-12">관심있는 스터디 주제</h2> </div> <div class="row"> <div class="col-12"> <div class="alert alert-info" role="alert"> 참여하고 싶은 스터디 주제를 입력해 주세요. 스터디가 생기면 알림을 받을 수 있습니다. 태그 입력 후 콤마(,) 또는 엔터를 입력하세요. </div> <input id="tags" type="text" name="tags" class="tagify-outside" aria-describedby="tagHelp"/> </div> </div> </div> </div> </div> <script type="application/javascript" th:inline="javascript"> $(function () { var csrfToken = /*[[${_csrf.token}]]*/ null; var csrfHeader = /*[[${_csrf.headerName}]]*/ null; $(document).ajaxSend(function (e, xhr, options){ xhr.setRequestHeader(csrfHeader, csrfToken); }); }); </script> <script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify@3.5.1/dist/tagify.min.js"></script> <script type="application/javascript" th:inline="javascript"> $(function() { function tagRequest(url, tagTitle) { $.ajax({ dataType: "json", autocomplete: { enabled: true, rightKey: true, }, contentType: "application/json; charset=utf-8", method: "POST", url: "[(${baseUrl})]" + url, data: JSON.stringify({'tagTitle': tagTitle}) }).done(function (data, status) { console.log("${data} and status is ${status}"); }); } function onAdd(e) { tagRequest("/add", e.detail.data.value); } function onRemove(e) { tagRequest("/remove", e.detail.data.value); } var tagInput = document.querySelector("#tags"); var tagify = new Tagify(tagInput, { pattern: /^.{0,20}$/, whitelist: JSON.parse(document.querySelector("#whitelist").textContent), dropdown : { enabled: 1, // suggest tags after a single character input } // map tags }); tagify.on("add", onAdd); tagify.on("remove", onRemove); // add a class to Tagify's input element tagify.DOM.input.classList.add('form-control'); // re-place Tagify's input element outside of the element (tagify.DOM.scope), just before it tagify.DOM.scope.parentNode.insertBefore(tagify.DOM.input, tagify.DOM.scope); }); </script> </body> </html>결과 화면
-
해결됨스프링과 JPA 기반 웹 애플리케이션 개발
7:35 부분에서 질문합니다.
혼자 여러 번 연습할 때 마다 여기서 계속 막혀서 적습니다. 코드는 다음과 같습니다.깃허브 주소: https://github.com/KrillM/studyclub @Test @DisplayName("회원 가입 처리 - 입력값 오류") public void signUpSubmit_wrongInputTest() throws Exception{ mockMvc.perform(post("/sign-up") .param("nickname", "keesun") .param("email", "email...") .param("password", "12345") .with(csrf())) .andExpect(status().isOk()) .andExpect(view().name("account/sign-up")); }
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
실제 구동은 되지만 테스트는 실패합니다.
강사님 현재 스프링과 JPA 기반 웹 애플리케이션을 듣는 중입니다.여러 번 반복하면서 개발 흐름을 파악하는 중인데요.AccountControllerTest에서 회원 가입 테스트- 잘못된 입력값을 테스트하는 중인데, 실제로는 구동이 잘 되지만 테스트 중에는 매번 테스트 실패로 뜹니다. 코드는 다음과 같습니다.@Test @DisplayName("회원 가입 테스트 - 잘못된 입력값") public void signUpSubmitTest_wrong() throws Exception{ mockMvc.perform(post("/sign-up") .param("nickname", "yena") .param("email", "yenice") .param("password", "12354") .with(csrf())) .andDo(print()) .andExpect(status().isOk()) .andExpect(view().name("account/sign-up")); }깃허브 주소: https://github.com/KrillM/studyclub이 문제를 넘어가기에는 앞으로 수업을 들으면서, 이후 포트폴리오를 만들 때 발목을 잡을 것 같아 질문합니다.
-
해결됨스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
session 객체를 thymeleaf 에서 어떻게 꺼낼 수 있죠?
@GetMapping("/basic-objects") public String basicObjects(HttpSession session) { ... }위 컨트롤러 작성하는 부분입니다.관련된 html 파일은 basic-objects 인데, ${#session} 으로 세션을 꺼내고 ${session} 으로도 세션을 꺼내네요.이게 가물가물한데 컨트롤러 메서드에서 파라미터로 호출하면 자동으로 모델에 넣어주기 때문에 thymeleaf 에서 ${session} 을 꺼낼 수 있는거죠?
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
SecurityConfig의 WebSecurityConfigurerAdapter 가 deprecated 되어 아래와 같이 코드를 수정하였는데 괜찮을까요?
안녕하세요 강의 잘 듣고 있습니다.해당 수업을 들으면서 코드를 직접 작성을 하고 있었는데 SecurityConfig의 WebSecurityConfigurerAdapter 가 deprecated가 되어서 인식이 안됬습니다.그래서 커뮤니티를 통해 어떤 오류가 났는지 다른 회원님의 글을 보고 알게 되어 해당 코드를 인용했음에도 오류가 발생하여 아래와 같이 코드를 수정을 했는데 괜찮을까요? package com.studyolle.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher; import org.springframework.security.web.util.matcher.RequestMatcher; import org.springframework.web.servlet.handler.HandlerMappingIntrospector; @Configuration //스프링 설정 클래스 @EnableWebSecurity //웹 보안 활성화, 웹 보안 설정 재정의 public class SecurityConfig { @Bean SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospector introspector) throws Exception { RequestMatcher[] matchers = { new MvcRequestMatcher(introspector, "/"), new MvcRequestMatcher(introspector, "/login"), new MvcRequestMatcher(introspector, "/sign-up"), new MvcRequestMatcher(introspector, "/check-email"), new MvcRequestMatcher(introspector, "/check-email-token"), new MvcRequestMatcher(introspector, "/email-login"), new MvcRequestMatcher(introspector, "/check-email-login"), new MvcRequestMatcher(introspector, "/login-link"), new MvcRequestMatcher(introspector, "/profile/*") }; //보안 요청에 대한 권한 및 역활 설정 http.authorizeRequests() //배열에 있는 경로들에 대한 모든 요청을 허용 .requestMatchers(matchers).permitAll() //지저오딘 경로외의 모든 요청은 인증된 사용자만 접근할 수 있도록 함 .anyRequest().authenticated(); // POST에 대한 별도 조건을 설정하려면 추가 코드 필요 return http.build(); } }
-
해결됨스프링과 JPA 기반 웹 애플리케이션 개발
SecurityConfig 파일 작성중,, WebSecurityConfigurerAdapter 가 deprecated 됬다고 해서 extends가 안됩니다.
안녕하세요. 강의를 열심히 들으려고 하는 한 직장인입니다. 해당 수업 (회원가입 컨트롤러) 를 듣는도중, SecurityConfig 파일 만드는 부분에서 WebSecurityConfigurerAdapter 가 deprecated 되었다고 extends가 안되고 있습니다. 저는 현재 스프링 시큐리티 버전을.. 6 버전대 사용중이에요. 정확히는 6.1.2 버전 사용하는것 같네요.. (이렇게 버전확인해도되는건지 몰르겠습니다..ㅠㅠ) 로그분석과,, 구글링을 좀 해본 결과, RequestMatchers(MvcRequestMatcher) orRequestMatchers(AntPathRequestMatcher) 의 패턴으로 사용을 해야한다고 해서,, 결국 소스를 수정하여. permitAll()은 해결하였습니다.그런데 강의에서 프로필 요청 url은 httpMethod중 get만 허용해야 하는 조건에서, mvcMatchers(HttpMethod.GET, "/profile/*").permitAll() 부분을 도무지 어떻게 대치해야할지를 모르겠습니다. 제가 현재 까지 작성한 소스 공유 드립니다. package com.studyolle.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher; import org.springframework.web.servlet.handler.HandlerMappingIntrospector; @Configuration @EnableWebSecurity // 시큐리티 활성화 -> 기본 스프링 필터체인에 등록 public class SecurityConfig { @Bean SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospector introspector) throws Exception { MvcRequestMatcher.Builder mvcMatcherBuilder = new MvcRequestMatcher.Builder(introspector); http.authorizeHttpRequests((requests) -> requests .requestMatchers( mvcMatcherBuilder.pattern("/"), mvcMatcherBuilder.pattern("/login"), mvcMatcherBuilder.pattern("/sign-up") ,mvcMatcherBuilder.pattern("/check-email"), mvcMatcherBuilder.pattern("/check-email-token"), mvcMatcherBuilder.pattern("/email-login") ,mvcMatcherBuilder.pattern("/check-email-login"), mvcMatcherBuilder.pattern("/login-link"), mvcMatcherBuilder.pattern("/profile/*") ).permitAll() .anyRequest().authenticated() ); return http.build(); } } 해결방안을 자세하게 알려주시면 감사하겠습니다. 시간이 지남에 따라 스프링 정책은 계속 deprecated 되는 것 같은데,,, 너무 나도 배울게 많다고 생각이 됩니다. 잠깐이라도 놓치면 개발의 세계와 너무 멀어지는 느낌이 드네요. 제가 많이 부족하여 따끔한 쓴소리도 같이 부탁드릴께요. 진심 열심히 하려고 노력중입니다.감사합니다. 빠른 답변 부탁드리겠습니다.
-
해결됨스프링과 JPA 기반 웹 애플리케이션 개발
강의대로했는데안되네요.
강의대로 했는데 안되네요. 우선 깃 링크로 접속하여 코드 다운로드받은뒤 압축풀어서 intellij 로 open 하여 해당 강의처럼 maven -> compile 더블클릭 했는데, 잘 돌던중 에러한줄이 뜹니다. /Users/jjeoV/Desktop/jjeoV/인프런/keesun/studyolle-master 2/target/classes/static/node_modules/.bin/jdenticon jdenticon 파일이 없는건가요? 그냥 딸랑 경로하나뜨니까 뭔지 잘 몰르겠네요. 감사합니다.
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
안녕하세요 압축프로그렘을 다운받은후에 compile해보니 오류가 발생해서 질문드립니다
이유가 뭘까요 사진 첨부해드릴게요 이거는 다른 글을 보니 추가해주니 해결되었다던데 저는 여젼히 컴파일에서 오류가 발생하네요
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
타임리프 파서 주석 궁금증
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]보면 <!--/* ... /--> 이 있고, <!--/*--> ... <!--*/--> 이 있는데, 본문에서는 그냥 한줄표현, 여러줄 표현이라고 하셨는데, 제가 해보니까 그런 차이는 아닌것 같더라구요.<!--/* ... */--> : 아예 소스 상 주석처리 상태. 그래서 절대경로로 열어도 뷰에는 안나옴<!--/*--> ... <!--*/--> : 소스상으론 주석처리 안된상태. 그래서 절대경로로 열면 뷰에 보임이렇게 해석했는데 맞는 내용일까요?
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
프로젝트 compile시 npm install시 No repository field
npm install시 위와같은 오류와 함께 컴파일이 종료됩니다. 혹시 해결 방법이 있나요?
-
해결됨스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
강의 다 듣고 혼자 하는중인데 도저히 이해가 안가서 여쭤봅니다..
<tr th:each="festival : ${festivalList}"> <td><a th:href="@{/festival/one(param=${festival})}" th:text="${festival.name}"></a> </td> 뷰 단에서 fetivalList을 보여줍니다. 그리고 리스트에서 each문 돌면서 모두 잘보여줍니다. 그리고 festival을 다시 쓸일이 있어서 url에 담아서 컨트롤러로 넘어가면 못받습니다. for문 뿐 아니라 객체 하나만 있는 상황에서도 안넘어가요 @GetMapping("/festival/one/search") public String searchFestivalOne(@ModelAttribute("param") Festival festival, Model model) throws IOException { System.out.println(festival.getName()); String[][] searchList = festivalService.jsonToList(festival.getName()); model.addAttribute(searchList); model.addAttribute(festival.getName()); return "/festival/festival_search.html"; }festival모델에 생성자문제라 생각해서 어노테이션 각각적용해서 모든 케이스 다해봤는데도 안되네요.. 에러는 안뜨고 그냥 null값만 나옵니다.타임리프에서 festival.(변수) 는 모두 잘넘어가는데 festival 만넘기면 바인딩처리가 안됩니다.@Entity @Getter @Setter @NoArgsConstructor @AllArgsConstructor public class Festival { @Id private long id; private String name; //축제명 private String location; //개최장소 private String startDate ;//축제시작일자 private String endDate ; //축제종료일자 private String content ; //축제내용 private String org ; //주관기관 private String open_org; //주최기관 private String sponsor; //후원기관 private String phone_num; //전화번호 private String homepage; //홈페이지주소 private String etc; //관련정보 private String location1; //소재지도로명주소 private String location2; //소재지지번주소 }
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
AppConfig클래스에 대해 질문있습니다 ㅎㅎ
안녕하세요 강의 6분에 PasswordEncoder 빈등록을 AppConfig 클래스를 하나 추가로 만들어서 하셨는데 저는 SecurityConfig에 추가로 등록해도 괜찮을것같다는 생각이들었는데 AppConfig을 추가했을때 어떤 이점이 있다고 생각하셔서 하신건지 궁금합니다!!
-
해결됨스프링과 JPA 기반 웹 애플리케이션 개발
사진 수정이 계속 안 됩니다.
cdn 방식으로 cropper를 사용하는 중이고요. 자바스크립트를 여러번 검토 하였음에도 프로필 사진 변경 문제는 끝까지 해결되지 않았습니다.https://www.youtube.com/watch?v=k330LVo2yw8setting.profile.html<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://thymeleaf.org/extras/spring-security"> <head th:fragment="head"> <meta charset="UTF-8"> <title>StudyOlle</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/jdenticon@3.2.0/dist/jdenticon.min.js" async integrity="sha384-yBhgDqxM50qJV5JPdayci8wCfooqvhFYbIKhv0hTtLvfeeyJMJCscRfFNKIxt43M" crossorigin="anonymous"> </script> <style> .container{ max-width:100%; } </style> </head> <nav th:fragment="main-nav" class="navbar navbar-expand-sm navbar-dark bg-dark"> <a class="navbar-brand" href="/" th:href="@{/}"> <img src="/images/logo_sm.png" width="30" height="30"> </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <form th:action="@{/search/study}" class="form-inline" method="get"> <input class="form-control mr-sm-2" name="keyword" type="search" placeholder="스터디 찾기" aria-label="Search"> </form> </li> </ul> <ul class="navbar-nav justify-content-end"> <li class="nav-item" sec:authorize="isAnonymous()"> <a class="nav-link" th:href="@{/login}">로그인</a> </li> <li class="nav-item" sec:authorize="isAnonymous()"> <a class="nav-link" th:href="@{/sign-up}">가입</a> </li> <li class="nav-item" sec:authorize="isAuthenticated()"> <a class="nav-link" th:href="@{/notifications}"> <i class="fa fa-bell-o" aria-hidden="true"></i> </a> </li> <li class="nav-item" sec:authorize="isAuthenticated()"> <a class="nav-link btn btn-outline-primary" th:href="@{/notifications}"> <i class="fa fa-plus" aria-hidden="true"></i> 모임 개설 </a> </li> <li class="nav-item dropdown" sec:authorize="isAuthenticated()"> <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <svg th:if="${#strings.isEmpty(account?.profileImage)}" th:data-jdenticon-value="${#authentication.name}" width="24" height="24" class="rounded border bg-light"></svg> <img th:if="${!#strings.isEmpty(account?.profileImage)}" th:src="${account.profileImage}" width="24" height="24" class="rounded border"/> </a> <div class="dropdown-menu dropdown-menu-sm-right" aria-labelledby="userDropdown"> <h6 class="dropdown-header"> <span sec:authentication="name">Username</span> </h6> <a class="dropdown-item" th:href="@{'/profile/' + ${#authentication.name}}">프로필</a> <a class="dropdown-item" >스터디</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="#" th:href="@{'/settings/profile'}">설정</a> <form class="form-inline my-2 my-lg-0" action="#" th:action="@{/logout}" method="post"> <button class="dropdown-item" type="submit">로그아웃</button> </form> </div> </li> </ul> </div> </nav> <footer th:fragment="footer"> <div class="row justify-content-center"> <img class="mb-2" src="/images/logo_lang_kr.jpg" alt="" width="100"> <small class="d-block mb-3 text-muted">© 2023</small> </div> </footer> <div th:fragment="settings-menu (currentMenu)" class="list-group"> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'profile'}? active" href="#" th:href="@{/settings/profile}">프로필</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'password'}? active" href="#" th:href="@{/settings/password}">비밀번호</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'notification'}? active" href="#" th:href="@{/settings/notification}">알림</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'tags'}? active" href="#" th:href="@{/settings/tags}">관심 주제</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'zones'}? active" href="#" th:href="@{/settings/zones}">활동 지역</a> <a class="list-group-item list-group-item-action list-group-item-danger" th:classappend="${currentMenu == 'account'}? active" href="#" th:href="@{/settings/account}">계정</a> </div> <script type="application/javascript" th:fragment="form-validation"> (function () { 'use strict'; window.addEventListener('load', function () { // Fetch all the forms we want to apply custom Bootstrap validation styles to var forms = document.getElementsByClassName('needs-validation'); // Loop over them and prevent submission Array.prototype.filter.call(forms, function (form) { form.addEventListener('submit', function (event) { if (form.checkValidity() === false) { event.preventDefault(); event.stopPropagation(); } form.classList.add('was-validated') }, false) }) }, false) }()) </script> </html>fragments.html<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://thymeleaf.org/extras/spring-security"> <head th:fragment="head"> <meta charset="UTF-8"> <title>StudyOlle</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/jdenticon@3.2.0/dist/jdenticon.min.js" async integrity="sha384-yBhgDqxM50qJV5JPdayci8wCfooqvhFYbIKhv0hTtLvfeeyJMJCscRfFNKIxt43M" crossorigin="anonymous"> </script> <style> .container{ max-width:100%; } </style> </head> <nav th:fragment="main-nav" class="navbar navbar-expand-sm navbar-dark bg-dark"> <a class="navbar-brand" href="/" th:href="@{/}"> <img src="/images/logo_sm.png" width="30" height="30"> </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <form th:action="@{/search/study}" class="form-inline" method="get"> <input class="form-control mr-sm-2" name="keyword" type="search" placeholder="스터디 찾기" aria-label="Search"> </form> </li> </ul> <ul class="navbar-nav justify-content-end"> <li class="nav-item" sec:authorize="isAnonymous()"> <a class="nav-link" th:href="@{/login}">로그인</a> </li> <li class="nav-item" sec:authorize="isAnonymous()"> <a class="nav-link" th:href="@{/sign-up}">가입</a> </li> <li class="nav-item" sec:authorize="isAuthenticated()"> <a class="nav-link" th:href="@{/notifications}"> <i class="fa fa-bell-o" aria-hidden="true"></i> </a> </li> <li class="nav-item" sec:authorize="isAuthenticated()"> <a class="nav-link btn btn-outline-primary" th:href="@{/notifications}"> <i class="fa fa-plus" aria-hidden="true"></i> 모임 개설 </a> </li> <li class="nav-item dropdown" sec:authorize="isAuthenticated()"> <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <svg th:if="${#strings.isEmpty(account?.profileImage)}" th:data-jdenticon-value="${#authentication.name}" width="24" height="24" class="rounded border bg-light"></svg> <img th:if="${!#strings.isEmpty(account?.profileImage)}" th:src="${account.profileImage}" width="24" height="24" class="rounded border"/> </a> <div class="dropdown-menu dropdown-menu-sm-right" aria-labelledby="userDropdown"> <h6 class="dropdown-header"> <span sec:authentication="name">Username</span> </h6> <a class="dropdown-item" th:href="@{'/profile/' + ${#authentication.name}}">프로필</a> <a class="dropdown-item" >스터디</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="#" th:href="@{'/settings/profile'}">설정</a> <form class="form-inline my-2 my-lg-0" action="#" th:action="@{/logout}" method="post"> <button class="dropdown-item" type="submit">로그아웃</button> </form> </div> </li> </ul> </div> </nav> <footer th:fragment="footer"> <div class="row justify-content-center"> <img class="mb-2" src="/images/logo_lang_kr.jpg" alt="" width="100"> <small class="d-block mb-3 text-muted">© 2023</small> </div> </footer> <div th:fragment="settings-menu (currentMenu)" class="list-group"> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'profile'}? active" href="#" th:href="@{/settings/profile}">프로필</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'password'}? active" href="#" th:href="@{/settings/password}">비밀번호</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'notification'}? active" href="#" th:href="@{/settings/notification}">알림</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'tags'}? active" href="#" th:href="@{/settings/tags}">관심 주제</a> <a class="list-group-item list-group-item-action" th:classappend="${currentMenu == 'zones'}? active" href="#" th:href="@{/settings/zones}">활동 지역</a> <a class="list-group-item list-group-item-action list-group-item-danger" th:classappend="${currentMenu == 'account'}? active" href="#" th:href="@{/settings/account}">계정</a> </div> <script type="application/javascript" th:fragment="form-validation"> (function () { 'use strict'; window.addEventListener('load', function () { // Fetch all the forms we want to apply custom Bootstrap validation styles to var forms = document.getElementsByClassName('needs-validation'); // Loop over them and prevent submission Array.prototype.filter.call(forms, function (form) { form.addEventListener('submit', function (event) { if (form.checkValidity() === false) { event.preventDefault(); event.stopPropagation(); } form.classList.add('was-validated') }, false) }) }, false) }()) </script> </html>SettingsController.java@Controller @RequiredArgsConstructor public class SettingsController { final static String SETTING_PROFILE_VIEW_NAME="settings/profile"; final static String SETTING_PROFILE_URL="/settings/profile"; private final AccountService accountService; @GetMapping(SETTING_PROFILE_URL) public String profileUpdateForm(@CurrentUser Account account, Model model){ model.addAttribute(account); model.addAttribute(new Profile(account)); return SETTING_PROFILE_VIEW_NAME; } @PostMapping(SETTING_PROFILE_URL) public String updateProfile(@CurrentUser Account account, @Valid Profile profile, Errors errors, Model model, RedirectAttributes attributes){ if(errors.hasErrors()){ model.addAttribute(account); return SETTING_PROFILE_VIEW_NAME; } accountService.updateProfile(account, profile); attributes.addFlashAttribute("message","프로필을 수정했습니다."); return "redirect:"+SETTING_PROFILE_URL; } }AccountService.javapublic void updateProfile(Account account, Profile profile){ account.setUrl(profile.getUrl()); account.setBio(profile.getBio()); account.setOccupation(profile.getOccupation()); account.setLocation(profile.getLocation()); account.setProfileImage(profile.getProfileImage()); accountRepository.save(account); }Profile.java@Data @NoArgsConstructor public class Profile { @Length(max = 35) private String bio; @Length(max = 50) private String url; @Length(max = 50) private String occupation; @Length(max = 50) private String location; private String profileImage; public Profile(Account account){ this.bio=account.getBio(); this.url=account.getUrl(); this.occupation=account.getOccupation(); this.location=account.getLocation(); this.profileImage=account.getProfileImage(); } }
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
html entity 인식 후 변환 시점
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]이해한 내용HTML 엔티티에 해당하는 html entity(<, >) 문자열을 입력했을때, escape(<, &rt) 문자로 변환된다.Thymeleaf 라이브러리에서 th:text, [[...]] 를 파싱할때는 escape 문자로 변환, th:utext, [(...)] 를 파싱할때는 < 를 문자열 그대로 입력 .위의 내용대로 이해하였습니다!제대로 이해한게 맞다면 어떤 시점에서 이뤄지는것인지 궁금합니다.궁금한 점어떤 시점에서 escape 문자로 변환 혹은 문자열 입력이 되는것인지 궁금합니다.escape 문자로 변환 혹은 문자열 그대로 입력이 되는 시점이 SSR(서버사이드 렌더링)과정에서 이뤄지는것이 맞는지 궁금합니다!
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
강사님! 프론트엔드 라이브러리 설정 부분에서 오류가 납니다..
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project studyolle: Compilation failure[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?[ERROR][ERROR] -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException ./mvnw test 명령어를 입력하면 위에 오류가 나오면서 build failure라고 뜨네요.. 오류메시지처럼 자바 버전 문젠가 해서 제 맥북 환경변수쪽도 보니까 11로 잘 들어가 있는데 왜 그럴까요.
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
프로젝트 실행하기 강의에서 compile 클릭시
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.8.0:npm (npm install) on project studyolle: Failed to run task: 'npm install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 236 (Exit value: 236) -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException해당 오류가 찍히는데 버전 문제일까요.?
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
회원가입 인증 메일 확인
accountService 애서 processNewAccount 을 Account newAccount = saveNewAccount(signUpForm);;newAccount.getGenerateEmailCheckToken();accountRepository.flush();sendSignUpConfirmEmail(newAccount);로하면@Transactional 을 메서드 상단에 선언을 안해도 해결이 가능한데요. @Transactional 를 사용하지않고강제로 플러시를 해준경우에 추후에 문제가 될만 소지가 있을까요?