hibernate - Spring Mvc Controller - problem with delete -


i working in j2ee project (pojo layer, dao layer(hibernate), service layer(spring), view(spring mvc)) have table of articles after each row want add link remove it.

this view

<c:if test="${!empty articles}"> <table>     <tr>         <th>article id</th>         <th>article name</th>         <th>article desc</th>         <th>added date</th>         <th>operation</th>     </tr>      <c:foreach items="${articles}" var="article">         <tr>             <td><c:out value="${article.articleid}"/></td>             <td><c:out value="${article.articlename}"/></td>             <td><c:out value="${article.articledesc}"/></td>             <td><c:out value="${article.addeddate}"/></td>             <td><a href="articles/${article.articleid}">delete</a></td>         </tr>     </c:foreach> </table> 

here controller delete

@requestmapping(value="/articles/{articleid}", method=requestmethod.post) public string deletecontact(@pathvariable("articleid") integer articleid) {      articleservice.removearticle(articleid);      return "redirect:/articles.html"; } 

this servcice layer

    @transactional(propagation = propagation.required, readonly = false) public void removearticle(integer id) {     articledao.removearticle(id); } 

this dao layer (i try find article remove it)

    public void removearticle(integer id) {             //to article     article article = (article) sessionfactory.getcurrentsession().load(             article.class, id);     if (null != article) {         sessionfactory.getcurrentsession().delete(article);     }  } 

but when run project , click delete link, have 404 error etat http 404 - /spring3hibernate/articles/1 description requested resource (/ spring3hibernate/articles/1) not available

can me?

 <td><a href="articles/${article.articleid}">delete</a></td> 

this standard request, controller mapped post.

@requestmapping(value="/articles/{articleid}", method=requestmethod.post) 

in addition, looks big security issue. can write simple 10 lines program call using or post request /articles/1 /articles/{any number} , delete entire data. recommend take consideration while designing such applications.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -