Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8476669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:14:37+00:00 2026-06-10T18:14:37+00:00

I’m creating a simple training project. I’ve implemented a controller method, which deletes an

  • 0

I’m creating a simple training project. I’ve implemented a controller method, which deletes an item from the list. The method is looking like this:

@Controller
@RequestMapping(value = "/topic")
public class TopicController {

    @Autowired
    private TopicService service;

    ...

    @RequestMapping(value = "/deleteComment/{commentId}", method = RequestMethod.POST)
    public String deleteComment(@PathVariable int commentId, BindingResult result, Model model){

        Comment deletedComment = commentService.findCommentByID(commentId);
        if (deletedComment != null) {
            commentService.deleteComment(deletedComment);
        }

        return "refresh:";
   }

}

This method is called from the button-tag, which is looking in the following way:

<form><button formaction = "../deleteComment/1" formmethod = "post">delete</button></form>

In my project the form-tag is looking like a clickable button. But there is a serious problem: controller’s method is never triggered. How can I trigger it, using a button-tag?

P.S. the call is performed from the page with URI http://localhost:8080/simpleblog/topic/details/2 and controller’s URI is the http://localhost:8080/simpleblog/topic/deleteComment/2

UPDATE:

I’ve created hyperlink ‘delete’, clicking on which should delete a comment, and I received an exception

java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!

And it’s true: I really have no @ModelAttribute in my controller method, preceding BindingResult parameter. But I have no clue, which type of type should it be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:14:39+00:00Added an answer on June 10, 2026 at 6:14 pm

    <form>‘s method attribute is GET by default. I don’t know what are you trying to do with formmethod and formaction attributes, but in default HTML they mean nothing.

    You must try something like:

    <form action="../deleteComment/1" method="post">
        <button>delete</button>
    </form>
    

    EDIT:

    You are declaring some unused parameters in your method. BindingResult must be used with a @Valid annotated attribute (search @Valid here to see some examples), but this is not your case. So, please just try:

    @RequestMapping(value = "/deleteComment/{commentId}", method = RequestMethod.POST)
    public String deleteComment(@PathVariable int commentId){
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.