servlet.xml配置:
controller代码:
@Controller
@RequestMapping(value="/test")
public class MainContrlller {
@Autowired
private JdbcTemplate jdbcTemplate;
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String index() {
System.out.println(jdbcTemplate.queryForInt("select COUNT(*) from demo_org"));
return "test";
}
}
表:
结果:
spring mvc 与数据库连接
猜你喜欢
转载自201609032307.iteye.com/blog/2339069
今日推荐
周排行