在一个将由Spring连接的类中使用@Autowired的优缺点是什么?
为了澄清,我正在谈论@Autowired注释,而不是XML中的自动连线.
我可能只是不理解它,但对我来说它几乎看起来像一个反模式 - 你的类开始意识到它们与DI框架相关联,而不仅仅是POJO.也许我是一个贪婪的惩罚,但我喜欢有bean的外部XML配置,我喜欢有明确的布线,所以我确切知道什么是连线在哪里.
我开发我的hybris.And项目,我想在一些模板500Error.jsp ,但我不能处理500 error.Next我不能让JSP文件。
我收到此错误:
SEVERE: Servlet.service() for servlet DispatcherServlet threw exception
java.lang.NullPointerException
Aug 10, 2017 3:14:07 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Throwable, location=/serverError]
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
在 web.xml 文件中
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/serverError</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)
在 Controller.java 以下方法中
@RequestMapping(value = "serverError", method = RequestMethod.GET)
public String renderErrorPage(final Model model, HttpServletRequest httpRequest) throws CMSItemNotFoundException {
Run Code Online (Sandbox Code Playgroud)