想写一个简单的页面来测试接口,但我又不想麻烦的去配springmvc,就用了比较老的servlet
在web.xml是这样配置的
newDataQuery newDataQuery com.new.newDataQuery newDataQuery /newDataQuery
applicationContext-dao.xml下dao的配置
在action下可以这样访问dao
private NewResultDao cr; public NewResultDao getCr() { return cr; } public void setCr(NewResultDao cr) { public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext servletContext = this.getServletContext(); WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext); cr = (NewResultDao)ctx.getBean("newResultDao"); }