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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:09:10+00:00 2026-06-07T04:09:10+00:00

I’m learning Spring 3.1. My webapp name is acme. The url is roughly https://blah.blah.blah/acme

  • 0

I’m learning Spring 3.1.

My webapp name is “acme”.

The url is roughly https://blah.blah.blah/acme

That URL is set up to display the login.jsp

I have a “/login” mapping in my controller that my login.jsp submits to

If something goes wrong it return the user to the login.jsp with this url in the browser:
https://blah.blah.blah/acme/login

The “/login” mapping is set up to handle POST requests, so I am concerned about users bookmarking
https://blah.blah.blah/acme/login, and getting the error message of “GET request not supported”

So, I thought I would put in a function to handle GET requests to /login to reroute through my general mapping handler for “/” and “/home”:

Login.Controller.java

package gov.noaa.acme.controller;

import java.security.Principal;
import javax.servlet.http.*;

import org.springframework.stereotype.Controller;
import org.springframework.validation.*;
import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

import org.apache.log4j.Logger;

@Controller
public class LoginController {


    private static final Logger logger  = Logger.getLogger(LoginController.class);

    @RequestMapping({"/","home"})
    public String home(ModelMap model,HttpSession session,HttpServletRequest request) {

        // Do some stuff

        return "login";
    }
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login_get(){
        logger.debug("started...");
        return "forward:home";
    }

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public String login(@ModelAttribute("laph") LAPH laph, 
                        BindingResult bindingResult,
                        ModelMap model, 
                        HttpSession session,
                        HttpServletRequest request, 
                        HttpServletResponse response,
                        @RequestParam(required=true) String last_usertype) {

        if (bindingResult.hasErrors()) {
            logger.debug("Error returning home");
            return "home";
        }

        logger.debug("Started ....");  

        // Do authentication  


        if (!isAuthenticated) {
            model.put("status_message", error_message);       
            return "login";
        }

        // success, send newly authenticated user to a search page
        nextView = "search";
        return "redirect:" + nextView;
    }

}// end class LoginController

My logs show that I am not even reaching the controller method for handling GET requests for /login, I’m still getting the error messages that GET is not supported for /login.

Any ideas on how I can fix this?

Thanks

Steve

  • 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-07T04:09:13+00:00Added an answer on June 7, 2026 at 4:09 am

    I am concerned about users bookmarking https:// blah.blah.blah/acme/login, and getting the error message of “GET request not supported”.

    Your method signatures are correct; with the annotations you have placed on login_get and login, Spring will not be confused and will invoke the correct methods for GET and POST requests.

    Your method home is wrong; it returns the string "login", but I guess you do not have a view named login and that you would like it to invoke one of the login methods. In that case you should have returned “forward:login”, but this solution is not much better.

    My advice is:

    1. /home should render the home view, by using file home.jsp or whatever view technology you’re using.
    2. Use a HandlerInterceptor to check whether a user is logged in, and if not, only then you redirect him to the login url.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
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 am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
i want to parse a xhtml file and display in UITableView. what is the

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.