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 8172053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:39:45+00:00 2026-06-06T21:39:45+00:00

I’m trying to add an edit function to my web app but I’m having

  • 0

I’m trying to add an edit function to my web app but I’m having some problems using @RequestParam. The parameter it is getting is null which it shouldn’t be. I’m hoping someone can point out where I have made a mistake.

Here are the methods from the controller :

@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String getEdit(@RequestParam("customerId") Integer customerId, Model model) {
Customer existingCustomer = customerService.retrieveCustomer(customerId);
    model.addAttribute("customerAttribute", existingCustomer);
    return "edit-customer";
}

@RequestMapping(value = "/edit", method = RequestMethod.POST)
public String postEdit(@RequestParam("customerId") Integer customerId,
        @ModelAttribute("customerAttribute") @Valid Customer customer, BindingResult result) {
    if (result.hasErrors()) {
        return "edit-customer";
    }
    customer.setCustomerId(customerId);
    customerService.editCustomer(customer);
    return "redirect:/test/customer/list";

and the two jsp pages

edit-customer.jsp :

<body>

<h1>Edit Existing Customer</h1>

<c:url var="saveUrl" value="/test/customer/edit?customerId=${customerAttribute.customerId}" />
<form:form modelAttribute="customerAttribute" method="POST" action="${saveUrl}">
 <table>
  <tr>
   <td><form:label path="customerId">Customer Id:</form:label></td>
   <td><form:input path="customerId" disabled="true"/></td>
  </tr>

  <tr>
   <td><form:label path="customerCountry">Customer Country</form:label></td>
   <td><form:input path="customerCountry"/></td>
  </tr>

  <tr>
   <td><form:label path="customerName">Customer Name:</form:label></td>
   <td><form:input path="customerName"/></td>
  </tr>

 </table>

 <input type="submit" value="Save" />
</form:form>

</body>

view-all-customers.jsp :

<body>
<a href="<c:url value="/test/home"/>">Home</a>

<h1>Customers</h1>

<c:url var="addUrl" value="/test/customer/add" />
<c:url var="editUrl" value="/test/customer/edit?customerId=${customer.customerId}"/>
<c:if test="${!empty customers}">
<a href="${addUrl}">Add</a> 
</c:if>
<table style="border: 1px solid; width: 500px; text-align:center">
 <thead style="background:#ccc">
  <tr>
   <th>Customer Id</th>
   <th>Customer Country</th>
   <th>Customer Name</th>
   <th colspan="4"></th>
  </tr>
 </thead>
 <tbody>
 <c:forEach items="${customers}" var="customer">
  <tr>
   <td><c:out value="${customer.customerId}" /></td>
   <td><c:out value="${customer.customerCountry}" /></td> 
   <td><c:out value="${customer.customerName}" /></td>
   <td><a href="${editUrl}">Edit</a></td>
  </tr>
 </c:forEach>
 </tbody>
</table>

<c:if test="${empty customers}">
 There are currently no customers in the list. <a href="${addUrl}">Add</a> a customers.
</c:if>

</body>

Can anyone see why Integer customerId in the GET method is null?

Thank you,
D

  • 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-06T21:39:47+00:00Added an answer on June 6, 2026 at 9:39 pm

    You’re using ${customer.customerId} before it’s initialized:

    <!-- you use it here -->
    <c:url var="editUrl" value="/test/customer/edit?customerId=${customer.customerId}"/>
    <c:if test="${!empty customers}">
    ....
     <tbody>
     <!-- and initialize it here -->
     <c:forEach items="${customers}" var="customer">
      <tr>
       <td><c:out value="${customer.customerId}" /></td>
       <td><c:out value="${customer.customerCountry}" /></td> 
       <td><c:out value="${customer.customerName}" /></td>
       <td><a href="${editUrl}">Edit</a></td>
      </tr>
     </c:forEach>
     </tbody>
    </table>
    

    Simply set editUrl inside the loop:

    <c:if test="${!empty customers}">
    ....
     <tbody>
     <c:forEach items="${customers}" var="customer">
       <c:url var="editUrl" value="/test/customer/edit?customerId=${customer.customerId}"/>
      <tr>
       <td><c:out value="${customer.customerId}" /></td>
       <td><c:out value="${customer.customerCountry}" /></td> 
       <td><c:out value="${customer.customerName}" /></td>
       <td><a href="${editUrl}">Edit</a></td>
      </tr>
     </c:forEach>
     </tbody>
    </table>
    

    and it should work. You’d have to reset the editUrl for each customer anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.