admin管理员组文章数量:1794759
Spring mvc + mybatis web项目当系统启动时自动调用某个方法
1、添加WebContextListener.java
2、文件内容
package com.pt.controller.listener; import javax.servlet.ServletContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.ServletContextAware; import com.pt.controllerty.MyServer; @Service public class WebContextListener implements InitializingBean, ServletContextAware{ @Autowired private MyServer myServer; @Override public void setServletContext(ServletContext servletContext) { try { myServer.bind(1235); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void afterPropertiesSet() throws Exception { // TODO Auto-generated method stub } }3、添加配置内容
4、最后启动tomcat。
版权声明:本文标题:Spring mvc + mybatis web项目当系统启动时自动调用某个方法 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686616808a86665.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论