我无法在代码中找到问题,我希望使用链接中的ID和@PathVariable来检索数据
我的控制员:
@RequestMapping( "/reklam" )
public class RklamController {
@RequestMapping("/{advertise_id}")
public String reklamPage(@PathVariable String advertise_id, ModelMap model) throws IOException {
DataSource dataSource = DataSourceGenerator.getDataSource();
AdvertiseDaoImpl adD = new AdvertiseDaoImpl(dataSource);
Advertise advertise = adD.getAd(advertise_id);
int count = advertise.getCounter();
if( count == 0 ){
count = 1;
}else{
count += 1;
}
advertise.setCounter(count);
model.addAttribute("advertise", advertise);
return "reklam"; } }
和dao:
@Override
public Advertise getAd(String id) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
try{
String sql = " select * from Advertise where advertise_id = ? ";
Advertise advertise = (Advertise) jdbcTemplate.queryForObject(sql,new Object[]{id},
new BeanPropertyRowMapper(Advertise.class));
return advertise;
}catch (DataAccessException e){
}
return null;
}
当我运行它时显示:
它显示了这一行5次:
Thu Mar 23 16:43:30 AST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
答案 0 :(得分:0)
最后我发现了问题,这是因为我在数据库中留下了一些空字段并且我使用了select * query,它可以修复购买更改查询或不留空字段,但我不知道理解为什么,谁能解释一下?