「Spring入門」@Autowiredを利用するサンプルコード
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();
}
}