2017-08-03 8 views
0

これはこれはこれは、URLデータベース私はpwaSourceIdでゼロになっているのですが、私は13フォームのURLも渡しています。私もコントローラで印刷しています。

pwaSourceId-int 
name-varchar 
isDeleted-int 
createdBy-int 
createdTime-Timestamp 
modifiedBy-int 
modifiedTime-Timestamp 

http://localhost:7080/vitality-web/boardsource/update?pwaSourceId=13&name=Agile&isDeleted=0&createdBy=1&createdTime=2017-08-02%2005:00:00&modifiedBy=1&modifiedTime=2017-08-02%2005:00:00

ある

@RequestMapping(value="/update",method = RequestMethod.PUT) 
public void updateEmployeee(@ModelAttribute("PwaSourceDetails") PwaSourceDetails pwa1) 
{ 
System.out.println("pwa1.getPwaSourceID()"); //out is zero here also 
pwaSourceDetailsService.updatePwaSourceDetails(pwa1); 
} 

私のコントローラクラスである

public int updatePwaSourceDetails(PwaSourceDetails pwa){System.out.println("pwa.getPwaSourceID()"); //out is zero here 
    String query="update pwa_source set name='"+pwa.getName()+"',is_deleted='"+pwa.getIsDeleted()+"',created_by='"+pwa.getCreatedBy()+"',created_time='"+pwa.getCreatedTime()+"',modified_by='"+pwa.getModifiedBy()+"',modified_time='"+pwa.getModifiedTime()+"' where pwa_source_id="+pwa.getPwaSourceID()+""; 
    return jdbcTemplate.update(query); 
    } 

私Dao.javaクラスです

これは、私はあなたがGETリクエストのように、URLにパラメータを送信

root cause 

org.springframework.jdbc.BadSqlGrammarException: StatementCallback; 
bad SQL grammar [update pwa_source set name='nitish',is_deleted=0,created_by=1,created_time=,modified_by=1,modified_time= where pwa_source_id=0]; 
nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 
'modified_by=1,modified_time= where pwasourceid=0' at line 1 

答えて

0

を取得していますが、あなたのコントローラは、リクエストのボディにモデルを送信することを、期待しています。エラーですあなたはここに例を見つけることができます:https://stackoverflow.com/a/35880456/8319308

+0

以下のようなJSONのデータは私が – NITISH

+0

はあなたが 'PwaSourceDetails'のソースコードを提供することができ、まだも得る同じ結果とそれを使用していますか? –

0

あなたがここに@RequestParamを必要とし、あなたのコントローラメソッドは、この

@RequestMapping(value="/update",method = RequestMethod.PUT) 
public void updateEmployeee(@RequestParam("PwaSourceDetails") long pwa1) 
0

あなた@ModelAttribute("PwaSourceDetails")@RequestBodyに注釈を交換して送るようにする必要がありますので、あなたは、単一の番号としてpwaSourceIdを送信しています

{ 
    "pwaSourceId": "13", 
    "name": "Agile", 
    "isDeleted": "0", 
    "createdBy": "1", 
    "createdTime": "2017-08-02%2005:00:00", 
    "modifiedBy": "1", 
    "modifiedTime": "2017-08-02%2005:00:00" 
} 
関連する問題