2017-03-19 113 views
0

我無法找到我的代碼的問題,我想用一個id從鏈接和@PathVariable爲什麼我不能使用@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; 
} 

當我運行它,它表明:

enter image description here

它顯示了此行的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

是否有打印出來的堆棧跟蹤? – jmw5598

+3

你有沒有在控制器類中添加'@ Controller'註釋? – Blank

+0

請在調試級別啓用日誌並共享碼頭日誌。 –

回答

0

終於讓我發現了問題,那是因爲我離開的一些領域在數據庫中的空,我使用SELECT *查詢時,它可以是固定的團購更改查詢或不留空字段,但我不明白爲什麼,任何人都可以解釋?