-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
997190d
commit c524562
Showing
36 changed files
with
1,079 additions
and
516 deletions.
There are no files selected for viewing
107 changes: 57 additions & 50 deletions
107
src/main/java/com/community/jian/community/Controller/CutomizeController.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 |
---|---|---|
@@ -1,50 +1,57 @@ | ||
package com.community.jian.community.Controller; | ||
|
||
import com.community.jian.community.exception.ApplicationErrorMessage; | ||
import org.springframework.boot.web.servlet.error.ErrorController; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@Controller | ||
@RequestMapping("/error") | ||
public class CutomizeController implements ErrorController { | ||
|
||
|
||
@Override | ||
public String getErrorPath() { | ||
return "error"; | ||
} | ||
@RequestMapping( | ||
produces = {"text/html"} | ||
) | ||
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { | ||
HttpStatus status = this.getStatus(request); | ||
|
||
ModelAndView modelAndView = new ModelAndView("error"); | ||
if (status.is4xxClientError()){ | ||
modelAndView.addObject("message", ApplicationErrorMessage.REQUEST_ERROR.getMessage()); | ||
} | ||
if (status.is5xxServerError()){ | ||
modelAndView.addObject("message",ApplicationErrorMessage.SERVICE_HOT.getMessage()); | ||
} | ||
|
||
return modelAndView; | ||
} | ||
protected HttpStatus getStatus(HttpServletRequest request) { | ||
Integer statusCode = (Integer)request.getAttribute("javax.servlet.error.status_code"); | ||
if (statusCode == null) { | ||
return HttpStatus.INTERNAL_SERVER_ERROR; | ||
} else { | ||
try { | ||
return HttpStatus.valueOf(statusCode); | ||
} catch (Exception var4) { | ||
return HttpStatus.INTERNAL_SERVER_ERROR; | ||
} | ||
} | ||
} | ||
} | ||
package com.community.jian.community.Controller; | ||
|
||
import com.community.jian.community.dto.Pioneer; | ||
import com.community.jian.community.exception.ApplicationErrorMessage; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.web.servlet.error.ErrorController; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@Controller | ||
@RequestMapping("/error") | ||
public class CutomizeController implements ErrorController { | ||
|
||
@Value("${github.client.client_id}") | ||
private String client_id; | ||
|
||
@Override | ||
public String getErrorPath() { | ||
return "error"; | ||
} | ||
@RequestMapping( | ||
produces = {"text/html"} | ||
) | ||
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { | ||
HttpStatus status = this.getStatus(request); | ||
|
||
ModelAndView modelAndView = new ModelAndView("error"); | ||
Pioneer pioneer = new Pioneer(); | ||
pioneer.setClient_id(client_id); | ||
modelAndView.addObject("pioneer",pioneer); | ||
if (status.is4xxClientError()){ | ||
modelAndView.addObject("message", ApplicationErrorMessage.REQUEST_ERROR.getMessage()); | ||
} | ||
if (status.is5xxServerError()){ | ||
modelAndView.addObject("message",ApplicationErrorMessage.SERVICE_HOT.getMessage()); | ||
} | ||
|
||
return modelAndView; | ||
} | ||
protected HttpStatus getStatus(HttpServletRequest request) { | ||
Integer statusCode = (Integer)request.getAttribute("javax.servlet.error.status_code"); | ||
if (statusCode == null) { | ||
return HttpStatus.INTERNAL_SERVER_ERROR; | ||
} else { | ||
try { | ||
return HttpStatus.valueOf(statusCode); | ||
} catch (Exception var4) { | ||
return HttpStatus.INTERNAL_SERVER_ERROR; | ||
} | ||
} | ||
} | ||
} |
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
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
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
Binary file not shown.
Oops, something went wrong.