「Spring入門」@Autowiredを利用するサンプルコード

2017年11月3日

Javaコード
@WebServlet(“/address")
public class AddressServlet extends HttpServlet {

@Autowired private AddressService addressService;

@Override
protected void init(ServletConfig config) throws ServletException {
super.init(config);
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
addressService.doSomething();
}
}

Java

Posted by arkgame