servlet.xml配置:
[img]http://dl2.iteye.com/upload/attachment/0121/3750/d972c084-12c0-3e5c-89d6-007bac6250c5.jpg[/img]
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";
}
}
表:
[img]http://dl2.iteye.com/upload/attachment/0121/3752/18a74185-f703-352e-afc8-f1125b770600.jpg[/img]
结果:
[img]http://dl2.iteye.com/upload/attachment/0121/3754/22b9f67f-7300-3d20-a75b-2e8f91f7251c.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0121/3750/d972c084-12c0-3e5c-89d6-007bac6250c5.jpg[/img]
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";
}
}
表:
[img]http://dl2.iteye.com/upload/attachment/0121/3752/18a74185-f703-352e-afc8-f1125b770600.jpg[/img]
结果:
[img]http://dl2.iteye.com/upload/attachment/0121/3754/22b9f67f-7300-3d20-a75b-2e8f91f7251c.png[/img]