-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from puncha/release/v0.2.0
Release v0.2.0
- Loading branch information
Showing
19 changed files
with
156 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
package tk.puncha.configuration; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.HandlerExceptionResolver; | ||
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; | ||
|
||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
@Configuration | ||
public class WebConfig extends WebMvcConfigurerAdapter { | ||
|
||
@Bean Properties exceptionMappings(){ | ||
Properties mappings = new Properties(); | ||
mappings.put("OopsException", "exception/oops"); | ||
return mappings; | ||
} | ||
|
||
@Bean | ||
public HandlerExceptionResolver handlerExceptionResolver(){ | ||
SimpleMappingExceptionResolver resolver = new SimpleMappingExceptionResolver(); | ||
resolver.setDefaultErrorView("exception/default"); | ||
resolver.setExceptionAttribute("exception"); | ||
resolver.setExceptionMappings(exceptionMappings()); | ||
return resolver; | ||
} | ||
|
||
@Override | ||
public void configureViewResolvers(ViewResolverRegistry registry) { | ||
super.configureViewResolvers(registry); | ||
registry.jsp("/WEB-INF/jsp/", ".jsp"); | ||
} | ||
|
||
@Override | ||
public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { | ||
exceptionResolvers.add(handlerExceptionResolver()); | ||
} | ||
} |
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,22 @@ | ||
package tk.puncha.controllers; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import tk.puncha.exceptions.OopsException; | ||
|
||
@Controller | ||
@RequestMapping("/errors") | ||
public class ErrorController { | ||
@RequestMapping(path = {"", "index", "default"}, method = RequestMethod.GET) | ||
public String index() { | ||
final String msg = "Expected: controller used to showcase what happens when an exception is thrown"; | ||
throw new RuntimeException(msg); | ||
} | ||
|
||
@RequestMapping(path = "/oops", method = RequestMethod.GET) | ||
public String oops() { | ||
throw new OopsException(); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
package tk.puncha.exceptions; | ||
|
||
public class OopsException extends RuntimeException { | ||
@Override | ||
public String getMessage() { | ||
return "Oops!"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
<hr/> | ||
<div class="container"> | ||
<img class="pull-right" src="../images/spring-pivotal-logo.png"/> | ||
<img class="pull-right" src="/resources/images/spring-pivotal-logo.png"/> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%--@elvariable id="exception" type="java.lang.exception"--%> | ||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> | ||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
<jsp:include page="../common/header.jsp"/> | ||
<body> | ||
<jsp:include page="../common/nav.jsp"/> | ||
|
||
<div class="container"> | ||
<img src="/resources/images/pets.png"/> | ||
<h2>Something happened...</h2> | ||
<p>${exception.message}</p> | ||
</div> | ||
|
||
<jsp:include page="../common/footer.jsp"/> | ||
<jsp:include page="../common/scripts.jsp"/> | ||
|
||
</body> | ||
</html> |
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,28 @@ | ||
<%--@elvariable id="exception" type="java.lang.exception"--%> | ||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> | ||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
<jsp:include page="../common/header.jsp"/> | ||
<body> | ||
<jsp:include page="../common/nav.jsp"/> | ||
|
||
<div class="container"> | ||
<div class="panel panel-danger panel-exception"> | ||
<div class="panel-heading">Exceptions: ${exception.getMessage()} </div> | ||
<div class="panel-body"> | ||
<c:set var="stack" value="${exception.getStackTrace()}"/> | ||
<c:forEach var="stackItem" items='${stack}'> | ||
${stackItem} | ||
</c:forEach> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<jsp:include page="../common/footer.jsp"/> | ||
<jsp:include page="../common/scripts.jsp"/> | ||
|
||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
<div class="container"> | ||
<h2>Welcome</h2> | ||
<img src="../images/pets.png"/> | ||
<img src="<c:url value="/resources/images/pets.png"/>"/> | ||
</div> |
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,29 @@ | ||
.container { | ||
padding-top: 10px; | ||
width: 700px; | ||
} | ||
|
||
.form-horizontal { | ||
width: 100%; | ||
} | ||
|
||
input[type="text"] { | ||
height: 25px; | ||
} | ||
|
||
nav { | ||
width: 601px; | ||
} | ||
|
||
.navbar .nav > li > a { | ||
color: #000000; | ||
} | ||
|
||
.form-horizontal .control-label { | ||
text-align: left; | ||
} | ||
|
||
.panel-exception > .panel-body { | ||
height: 500px; | ||
overflow: scroll; | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes