-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/tobe/NotFoundHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package webmvc.org.springframework.web.servlet.mvc.tobe; | ||
|
||
import webmvc.org.springframework.web.servlet.ModelAndView; | ||
import webmvc.org.springframework.web.servlet.view.JspView; | ||
|
||
public class NotFoundHandler { | ||
|
||
public ModelAndView handle(String viewName) { | ||
return new ModelAndView(new JspView(viewName)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...src/main/java/webmvc/org/springframework/web/servlet/mvc/tobe/NotFoundHandlerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package webmvc.org.springframework.web.servlet.mvc.tobe; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import webmvc.org.springframework.web.servlet.ModelAndView; | ||
|
||
public class NotFoundHandlerAdapter implements HandlerAdapter { | ||
|
||
private final String viewName; | ||
|
||
public NotFoundHandlerAdapter(String viewName) { | ||
this.viewName = viewName; | ||
} | ||
|
||
@Override | ||
public boolean supports(Object handler) { | ||
return handler instanceof NotFoundHandler; | ||
} | ||
|
||
@Override | ||
public ModelAndView handle(Object handler, HttpServletRequest request, HttpServletResponse response) throws Exception { | ||
return ((NotFoundHandler) handler).handle(viewName); | ||
} | ||
} |