title: Spring boot: 404 error, when I submit html form
body: <p>I made two projects. One is a blog to write(I named it DevJournal), the other is login and registration(I name it Member).</p>
  <p>Both of them work fine.
  I put those projects into one.
  When I write and submit, it shows 404 error.
  Login and registeration(Member) works fine.</p>
  <p>I don't know what is the problem.</p>
  <p>Any help would be greatly appreciated.</p>
  <p><a href="https://i.stack.imgur.com/0bZ45.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0bZ45.png" alt="error page" /></a></p>
  <p><a href="https://i.stack.imgur.com/aabPW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aabPW.png" alt="directory" /></a></p>
  <p>DevJournalController</p>
  <pre><code>package com.opendev3.devjournal.controller;
  
  import com.opendev3.devjournal.dto.DevJournalDto;
  //import com.opendev3.devjournal.dto.MemberDto;
  import com.opendev3.devjournal.service.DevJournalService;
  //import com.opendev3.devjournal.service.MemberService;
  import lombok.AllArgsConstructor;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.*;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PostMapping;
  
  import java.util.List;
  
  @Controller
  @AllArgsConstructor
  public class DevJournalController {
      private DevJournalService devjournalService;
  
      /* 게시글 목록 */
      @GetMapping(&quot;/tidy&quot;)
      public String list(Model model) {
          List&lt;DevJournalDto&gt; devjournalList = devjournalService.getDevJournallist();
  
          model.addAttribute(&quot;devjournalList&quot;, devjournalList);
          return &quot;/devjournal/list&quot;;
      }
  
      @GetMapping(&quot;/tidy/post&quot;)
      public String write() {
          return &quot;/devjournal/write&quot;;
      }
  
      @PostMapping(&quot;/tidy/post&quot;)
      public String write(DevJournalDto devjournalDto) {
          devjournalService.savePost(devjournalDto);
          return &quot;redirect:/tidy&quot;;
      }
  
  
      @GetMapping(&quot;/tidy/post/{no}&quot;)
      public String detail(@PathVariable(&quot;no&quot;) Long no, Model model) {
          DevJournalDto devjournalDto = devjournalService.getPost(no);
  
          model.addAttribute(&quot;devjournalDto&quot;, devjournalDto);
          return &quot;/devjournal/detail&quot;;
      }
  
      @GetMapping(&quot;/tidy/post/edit/{no}&quot;)
      public String edit(@PathVariable(&quot;no&quot;) Long no, Model model) {
          DevJournalDto devjournalDTO = devjournalService.getPost(no);
  
          model.addAttribute(&quot;devjournalDto&quot;, devjournalDTO);
          return &quot;/devjournal/update&quot;;
      }
  
  
      @PutMapping(&quot;/tidy/post/edit/{no}&quot;)
      public String update(DevJournalDto devjournalDTO) {
          devjournalService.savePost(devjournalDTO);
  
          return &quot;redirect:/tidy&quot;;
      }
  
      @DeleteMapping(&quot;/tidy/post/{no}&quot;)
      public String delete(@PathVariable(&quot;no&quot;) Long no) {
          devjournalService.deletePost(no);
  
          return &quot;redirect:/tidy&quot;;
      }
  }
  </code></pre>
  <p>MemberController</p>
  <pre><code>package com.opendev3.devjournal.controller;
  
  import com.opendev3.devjournal.dto.MemberDto;
  import com.opendev3.devjournal.service.MemberService;
  import lombok.AllArgsConstructor;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PostMapping;
  
  @Controller
  @AllArgsConstructor
  public class MemberController {
      private MemberService memberService;
  
      // 메인 페이지
      @GetMapping(&quot;/&quot;)
      public String index() {
          return &quot;/member/index&quot;;
      }
  
      // 회원가입 페이지
      @GetMapping(&quot;/user/signup&quot;)
      public String dispSignup() {
          return &quot;/member/signup&quot;;
      }
  
      // 회원가입 처리
      @PostMapping(&quot;/user/signup&quot;)
      public String execSignup(MemberDto memberDto) {
          memberService.joinUser(memberDto);
  
          return &quot;redirect:/user/login&quot;;
      }
  
      // 로그인 페이지
      @GetMapping(&quot;/user/login&quot;)
      public String dispLogin() {
          return &quot;/member/login&quot;;
      }
  
      // 로그인 결과 페이지
      @GetMapping(&quot;/user/login/result&quot;)
      public String dispLoginResult() {
          return &quot;redirect:/tidy&quot;;
          //return &quot;/member/loginSuccess&quot;;
      }
  
      // 로그아웃 결과 페이지
      @GetMapping(&quot;/user/logout/result&quot;)
      public String dispLogout() {
          return &quot;/member/logout&quot;;
      }
  
  
  }
  </code></pre>
  <p>DevJournalEntity</p>
  <pre><code>package com.opendev3.devjournal.domain.entity;
  
  import lombok.AccessLevel;
  import lombok.Builder;
  import lombok.Getter;
  import lombok.NoArgsConstructor;
  
  import javax.persistence.*;
  
  @NoArgsConstructor(access = AccessLevel.PROTECTED)
  @Getter
  @Entity
  @Table(name = &quot;devjournal&quot;)
  
  public class DevJournalEntity extends TimeEntity{
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      private Long tidyid;
  
      @Column(length = 100, nullable = false)
      private String title;
  
      @Column(columnDefinition = &quot;TEXT&quot;, nullable = false)
      private String emotion;
  
      @Column(columnDefinition = &quot;TEXT&quot;, nullable = false)
      private String curiosity;
  
      @Column(columnDefinition = &quot;TEXT&quot;, nullable = false)
      private String improvement;
  
      @Column(columnDefinition = &quot;TEXT&quot;, nullable = false)
      private String problem;
  
      @Builder
      public DevJournalEntity(Long tidyid, String title, String emotion,String curiosity, String improvement, String problem) {
          this.tidyid = tidyid;
          this.title = title;
          this.emotion = emotion;
          this.curiosity = curiosity;
          this.improvement = improvement;
          this.problem = problem;
      }
  
  }
  </code></pre>
  <p>TimeEntity</p>
  <pre><code>package com.opendev3.devjournal.domain.entity;
  
  import lombok.Getter;
  import org.springframework.data.annotation.CreatedDate;
  import org.springframework.data.annotation.LastModifiedDate;
  import org.springframework.data.jpa.domain.support.AuditingEntityListener;
  
  import javax.persistence.Column;
  import javax.persistence.EntityListeners;
  import javax.persistence.MappedSuperclass;
  import java.time.LocalDateTime;
  
  @Getter
  @MappedSuperclass
  @EntityListeners(AuditingEntityListener.class)
  
  public abstract class TimeEntity {
      @CreatedDate
      @Column(updatable = false)
      private LocalDateTime createdDate;
  
      @LastModifiedDate
      private LocalDateTime modifiedDate;
  }
  </code></pre>
  <p>DevJournalDto</p>
  <pre><code>package com.opendev3.devjournal.dto;
  
  import com.opendev3.devjournal.domain.entity.DevJournalEntity;
  
  import lombok.*;
  
  import java.time.LocalDateTime;
  
  @Getter
  @Setter
  @ToString
  @NoArgsConstructor
  public class DevJournalDto {
      private Long tidyid;
      private String title;
      private String emotion;
      private String curiosity;
      private String improvement;
      private String problem;
      private LocalDateTime createdDate;
      private LocalDateTime modifiedDate;
  
      public DevJournalEntity toEntity(){
          DevJournalEntity devjournalEntity = DevJournalEntity.builder()
                  .tidyid(tidyid)
                  .title(title)
                  .emotion(emotion)
                  .curiosity(curiosity)
                  .improvement(improvement)
                  .problem(problem)
                  .build();
          return devjournalEntity;
      }
  
      @Builder
      public DevJournalDto(Long tidyid, String title, String curiosity, String emotion, String improvement, String problem,
                            LocalDateTime createdDate, LocalDateTime modifiedDate) {
          this.tidyid = tidyid;
          this.title = title;
          this.emotion = emotion;
          this.curiosity = curiosity;
          this.improvement = improvement;
          this.problem = problem;
          this.createdDate = createdDate;
          this.modifiedDate = modifiedDate;
      }
  
  }
  </code></pre>
  <p>DevJournalService</p>
  <pre><code>package com.opendev3.devjournal.service;
  
  import com.opendev3.devjournal.domain.entity.DevJournalEntity;
  import com.opendev3.devjournal.dto.DevJournalDto;
  import com.opendev3.devjournal.domain.repository.DevJournalRepository;
  import lombok.AllArgsConstructor;
  import org.springframework.stereotype.Service;
  
  import javax.transaction.Transactional;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Optional;
  
  @AllArgsConstructor
  @Service
  public class DevJournalService {
      private DevJournalRepository devjournalRepository;
  
      @Transactional
      public List&lt;DevJournalDto&gt; getDevJournallist() {
          List&lt;DevJournalEntity&gt; devjournalEntities = devjournalRepository.findAll();
          List&lt;DevJournalDto&gt; devjournalDtoList = new ArrayList&lt;&gt;();
  
          for ( DevJournalEntity devjournalEntity : devjournalEntities) {
              DevJournalDto devjournalDTO = DevJournalDto.builder()
                      .tidyid(devjournalEntity.getTidyid())
                      .emotion(devjournalEntity.getEmotion())
                      .curiosity(devjournalEntity.getCuriosity())
                      .improvement(devjournalEntity.getImprovement())
                      .problem(devjournalEntity.getProblem())
                      .title(devjournalEntity.getTitle())
                      .createdDate(devjournalEntity.getCreatedDate())
                      .build();
  
              devjournalDtoList.add(devjournalDTO);
          }
  
          return devjournalDtoList;
      }
  
  
      @Transactional
      public DevJournalDto getPost(Long tidyid) {
          Optional&lt;DevJournalEntity&gt; devjournalEntityWrapper = devjournalRepository.findById(tidyid);
          DevJournalEntity devjournalEntity = devjournalEntityWrapper.get();
  
          DevJournalDto devjournalDTO = DevJournalDto.builder()
                  .tidyid(devjournalEntity.getTidyid())
                  .emotion(devjournalEntity.getEmotion())
                  .curiosity(devjournalEntity.getCuriosity())
                  .improvement(devjournalEntity.getImprovement())
                  .problem(devjournalEntity.getProblem())
                  .title(devjournalEntity.getTitle())
                  .createdDate(devjournalEntity.getCreatedDate())
                  .build();
  
          return devjournalDTO;
      }
  
      @Transactional
      public Long savePost(DevJournalDto devjournalDto) {
          return devjournalRepository.save(devjournalDto.toEntity()).getTidyid();
      }
  
      @Transactional
      public void deletePost(Long tidyid) {
  
          devjournalRepository.deleteById(tidyid);
      }
  }
  </code></pre>
  <p>list.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot; xmlns:th=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;정리창&lt;/title&gt;
  
      &lt;link rel=&quot;stylesheet&quot; th:href=&quot;@{/css/devjournal.css}&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;a th:href=&quot;@{/tidy/post}&quot;&gt;write&lt;/a&gt;
  
  &lt;table&gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;th class=&quot;ten wide&quot;&gt;title&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
      &lt;!-- CONTENTS !--&gt;
      &lt;tr th:each=&quot;devjournal : ${devjournalList}&quot;&gt;
          &lt;td&gt;
              &lt;a th:href=&quot;@{'/post/' + ${devjournal.tidyid}}&quot;&gt;
                  &lt;span th:text=&quot;${devjournal.title}&quot;&gt;&lt;/span&gt;
              &lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>write.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;정리창&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form  action=&quot;/tidy/post&quot; method=&quot;post&quot;&gt;
          &lt;p&gt;title&lt;br&gt;
              &lt;input type=&quot;text&quot; name=&quot;title&quot;&gt;
          &lt;/p&gt;
          &lt;p&gt;느낀점&lt;br&gt;
              &lt;textarea name=&quot;emotion&quot;&gt;&lt;/textarea&gt;&lt;br&gt;
          &lt;/p&gt;
           &lt;p&gt;궁금한 점&lt;br&gt;
              &lt;textarea name=&quot;curiosity&quot;&gt;&lt;/textarea&gt;&lt;br&gt;
          &lt;/p&gt;
          &lt;p&gt;개선할 점&lt;br&gt;
              &lt;textarea name=&quot;improvement&quot;&gt;&lt;/textarea&gt;&lt;br&gt;
          &lt;/p&gt;
          &lt;p&gt;문제점&lt;br&gt;
              &lt;textarea name=&quot;problem&quot;&gt;&lt;/textarea&gt;&lt;br&gt;
          &lt;/p&gt;
          &lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>application.yml</p>
  <pre><code>spring:
    datasource:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/opendev?serverTimezone=UTC&amp;characterEncoding=UTF-8
      username: root
      password: 
  
    mvc:
      hiddenmethod:
        filter:
          enabled: true
  
  
    jpa:
      database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
      open-in-view: false
      show-sql: true
      hibernate:
        format_sql: true
        ddl-auto: create
  
  logging:
    level:
      org:
        hibernate:
          SQL: DEBUG
          type:
            descriptor:
              sql:
                BasicBinder: TRACE
  </code></pre>
  <p>build.gradle</p>
  <pre><code>plugins {
      id 'org.springframework.boot' version '2.5.6'
      id 'io.spring.dependency-management' version '1.0.11.RELEASE'
      id 'java'
  }
  
  group = 'com.example.opendev3'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '11'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      implementation 'org.springframework.boot:spring-boot-starter'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
  
  
      implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
      implementation 'org.springframework.boot:spring-boot-starter-web'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
  
      //롬복 설정
      compileOnly 'org.projectlombok:lombok'
      annotationProcessor 'org.projectlombok:lombok'
      annotationProcessor 'org.projectlombok:lombok'
      testAnnotationProcessor 'org.projectlombok:lombok'
  
      runtimeOnly 'mysql:mysql-connector-java'
  
      implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
  
      developmentOnly 'org.springframework.boot:spring-boot-devtools'
  
      implementation 'org.springframework.boot:spring-boot-starter-security'
      implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
  }
  
  test {
      useJUnitPlatform()
  
      configurations {
          developmentOnly
          runtimeClasspath {
              extendsFrom developmentOnly
          }
          compileOnly {
              extendsFrom annotationProcessor
          }
      }
  
      repositories {
          mavenCentral()
      }
  
      dependencies {
          implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
          implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
          implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
          implementation 'org.springframework.boot:spring-boot-starter-web'
          implementation 'org.springframework.boot:spring-boot-starter-security'
          compileOnly 'org.projectlombok:lombok'
          developmentOnly 'org.springframework.boot:spring-boot-devtools'
          runtimeOnly 'mysql:mysql-connector-java'
          annotationProcessor 'org.projectlombok:lombok'
          testImplementation 'org.springframework.boot:spring-boot-starter-test'
      }
  }
  </code></pre>