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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:10:11+00:00 2026-05-21T16:10:11+00:00

this is my view for /weather: JSP FILE …. <form method=post action=/spring/krams/show/city> <select name=city>

  • 0

this is my view for /weather:

JSP FILE

....
<form method="post" action="/spring/krams/show/city">
<select name="city">
<c:forEach items="${cities}" var="city">
    <option value="<c:out value="${city.id}" />"><c:out value="${city.city}" /></option>
</c:forEach>
</select>
<input type="submit" value="Test" name="submit" />
</form>
.....

PICTURE!!
enter image description here

this is my controller for the /weather:

    @RequestMapping(value = "/weather", method = RequestMethod.GET)
public String getCurrentWeather(Model model) {
    logger.debug("Received request to show cities page");

    // Attach list of subscriptions to the Model
    model.addAttribute("cities",  service.getAllCities());

    // This will resolve to /WEB-INF/jsp/subscribers.jsp
    return "weather";
}

this is my view for /city:

JSP FILE!

....
<h1>Cities</h1>
<c:out value="${city.city}" />
....

this is my controller for the /city:

    @RequestMapping(value = "/city", method = RequestMethod.GET)
public String getCurrentCity(Model model) {
    logger.debug("Received request to show cities page");


    model.addAttribute("city",  service.getCity(2));

    // This will resolve to /WEB-INF/jsp/citys.jsp
    return "city";
}

when i press the button, it should go to my /city page and show the city which i got from service.getCity(2) .

MY PROBLEM:

when i just go to the url /city it gets the second city from database..IT WORKS..getCity method works…but when i press the submit button, it does not work .. it gives me tons of error..but i think i’m just using the syntax wrong

MY QUESTION:
basically i want it to pass the dropbox value to /city and in /city controller it should getCity(x) , at the moment i am using getCity(2) for testing . how can i do it?

ASK IF YOU HAVE QUESTIONS!!!

  • 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-05-21T16:10:12+00:00Added an answer on May 21, 2026 at 4:10 pm

    The method getCurrentCity is annotated with @RequestMapping with parameter method=RequestMethod.GET, change it to RequestMethod.POST

    Also change your method signature to:

    public String getCurrentCity(@RequestParam("city") int city_id, Model model)
    

    and call your service’s getCity method using city_id

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

Sidebar

Related Questions

this is how I define the loaction of my jsp files: <bean id=jspViewResolver class=org.springframework.web.servlet.view.InternalResourceViewResolver>
Is there any way to show data in the grid view form in ipad
Assume this view: SELECT [Pr].[Id], [Pr].[Title], [Pr].[Category_Id] AS [CategoryId], [Pr].[IsScanAllowed], [Pr].[MaxLevelOfRegistration], [Cat].[Title] AS [Category],
How can I achieve this view with CSS: ------------------TITLE or TITLE------------------ I have <div
I have this view @model IEnumerable<ViewModelRound2> ... <snip> ... @{ using (Html.BeginForm(new { round1Ring3Bids
I have this view (DetailsContainer, first class in code section of this question) with
I want to implement this view But I have one question: The text which
I created a new View (LogView) in Infrastructure.Module project. This view will be used
I have a Django view called change_priority. I'm posting a request to this view
I'm displaying a UIView with a UILabel on it and this view&label become blurry

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.