Ошибка request method post not supported

First of all say apology to ask this repeated Question..

Actually in my spring Application i have user.jsp and professional.jsp

here is my User.jsp:

  <form:form action="profile/user" modelAttribute="profile">
    <div>
        <jsp:include page="professional.jsp"></jsp:include>
    </div>

</form:form>

And here is my professional.jsp:

   <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<fieldset id="profile_proffiesional">
    <form:form action="profile/proffiesional" modelAttribute="PROFESSIONAL" method="POST">
        <p>
            <label for="position">Position</label>
            <form:input path="position" tabindex="4" />
        </p>
        <p>
            <label for="location">Location</label>
            <form:input path="location" tabindex="5" />
        </p>
        <p>
            <label for="description">Description</label>
            <form:input path="description" tabindex="5" />
        </p>
        <p>
            <input type="submit" value="Add">
        </p>
    </form:form>
</fieldset>

And here is my Controller class:

    @Controller
@RequestMapping(value = "profile")
public class UserProfileController {

    @Autowired
    private UserService userService;

    @Autowired
    private SessionData sessionData;

    @RequestMapping(value = "user", method = RequestMethod.GET)
    public String user(Model model) throws Exception {
        model.addAttribute("PROFESSIONAL", new UserProfessionalForm());
        model.addAttribute("EDUCATIONAL", new UserEducationalForm());
        model.addAttribute("AWARDS", new UserAwardsForm());
        return "profile/user";
    }

    @RequestMapping(value = "proffessional", method = RequestMethod.POST)
    public @ResponseBody
    String forgotPassword(UserProfessionalForm professionalForm,
            BindingResult result, Model model) {

        UserProfileVO userProfileVO = new UserProfileVO();
        userProfileVO.setUser(sessionData.getUser());
        userService.saveUserProfile(userProfileVO);
        model.addAttribute("professional", professionalForm);
        return "Your Professional Details Updated";
    }
}

Problem is when we are Click Add button in professional.jsp, there is no response in server console but below warning message shown:

  29 Mar, 2013 1:03:51 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported
WARNING: Request method 'POST' not supported

Why this Warning coming? i’m already specified method=»POST»..

Please help..

First of all say apology to ask this repeated Question..

Actually in my spring Application i have user.jsp and professional.jsp

here is my User.jsp:

  <form:form action="profile/user" modelAttribute="profile">
    <div>
        <jsp:include page="professional.jsp"></jsp:include>
    </div>

</form:form>

And here is my professional.jsp:

   <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<fieldset id="profile_proffiesional">
    <form:form action="profile/proffiesional" modelAttribute="PROFESSIONAL" method="POST">
        <p>
            <label for="position">Position</label>
            <form:input path="position" tabindex="4" />
        </p>
        <p>
            <label for="location">Location</label>
            <form:input path="location" tabindex="5" />
        </p>
        <p>
            <label for="description">Description</label>
            <form:input path="description" tabindex="5" />
        </p>
        <p>
            <input type="submit" value="Add">
        </p>
    </form:form>
</fieldset>

And here is my Controller class:

    @Controller
@RequestMapping(value = "profile")
public class UserProfileController {

    @Autowired
    private UserService userService;

    @Autowired
    private SessionData sessionData;

    @RequestMapping(value = "user", method = RequestMethod.GET)
    public String user(Model model) throws Exception {
        model.addAttribute("PROFESSIONAL", new UserProfessionalForm());
        model.addAttribute("EDUCATIONAL", new UserEducationalForm());
        model.addAttribute("AWARDS", new UserAwardsForm());
        return "profile/user";
    }

    @RequestMapping(value = "proffessional", method = RequestMethod.POST)
    public @ResponseBody
    String forgotPassword(UserProfessionalForm professionalForm,
            BindingResult result, Model model) {

        UserProfileVO userProfileVO = new UserProfileVO();
        userProfileVO.setUser(sessionData.getUser());
        userService.saveUserProfile(userProfileVO);
        model.addAttribute("professional", professionalForm);
        return "Your Professional Details Updated";
    }
}

Problem is when we are Click Add button in professional.jsp, there is no response in server console but below warning message shown:

  29 Mar, 2013 1:03:51 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported
WARNING: Request method 'POST' not supported

Why this Warning coming? i’m already specified method=»POST»..

Please help..

Many errors can prompt a page in any search engine. The most common ones are the 404 Not Found Error and the 404 Not Supported Error. Yeah, once in a while, you might encounter this notification; the request method’ post’ is not supported. This prompt gives no one an option but to leave the page. Take it this way; the error message prompts in your website, yet you depend on these search engines to generate more traffic into your website. The results are annoying and hurt your business because you lose a chance to gain new customers.

But, what exactly does this request method ‘post’ is not supported mean? How do you get around this issue? Addressing this problem can be challenging. However, we have given the best way to address this error message whenever it pops on your page.

Read through to learn how to.

What Does the Request Method’ POST’ Not Supported Mean?

The Request Method’ POST’ Not Supported’ is an HTTP response status. The error prompt shows that a request to access your website has been sent from a web browser. Despite your web server receiving and recognizing the request, it cannot grant the requested site page access. This error is due to the unsupported HyperText Transfer Protocol (HTTP) method. This feature means that the browser requesting access to your site page cannot access it.

The specific browser your visitor is using will show an error page rather than the page they requested. Most browsers will display a 404 Not Allowed Error; this prompt is what your visitor will see on their browser pages. Such browsers include Firefox, Google Chrome, and Microsoft Edge.

This error page is one of the common errors visitors and web developers encounter once in a while. You might see your browser pages taking long to load, links breaking, and so on. As a Web developer, you should always address such issues almost immediately; otherwise, you’ll lose more visitors, resulting in a sales drop.

What Causes the Request Method ‘POST’ Not Supported Error?

The Request Method’ POST’ Not Supported error is caused by a mismatch of the web browser configuration and the browser’s URL format. In this case, the browser sends a URL request, the web server receives and recognizes the URL but cannot execute commands or grant access to the requested page. Despite the server recognizing the URL format, the target page does not support such format. The web server will send an error message to the browser, showing an error page.

What Format does the Request Method ‘POST’ Not Supported Error Display?

The Request Method’ POST’ Not Supported error can appear in different formats depending on the browser, Operating Systems, and web servers.

Below is how this error can appear on your browser.

  • HTTP 405 Error
  • HTTP 405 Method Not Allowed
  • 405 Not Allowed
  • HTTP Error 405 – Method Not Allowed
  • Method Not Allowed

No matter the format in which the error appears, you must immediately restore your browser. The process might be challenging, but we have swiftly helped you navigate the issue. Here’s is how to.

What Are the Best Methods to Solve the Request Method’ Post’ Not Supported Error?

Try the following methods to solve this error.

Confirm That Your Input URL Is Correct

The wrong URL is the primary cause of this error, as web servers prevent visitors from accessing the wrong pages. Therefore, you should check it to confirm that all is good. Be sure to confirm that your spelling is correct and that you’ve included all letters.

Confirm if You Have Database Changes

Plugins can modify database records under WordPress without notice. When you uninstall such plugins, they can’t revert the earlier changes; instead, they ignore them. This condition may result in Request Method’ POST’ Not Supported error when left unaddressed.

Therefore, you need to check your database to see the changes. You can do this by opening the database and going through the table to identify the plugins’ changes. If you find this process challenging, seek help from your web developer.

Check the Server’s Configuration

You should check your website server’s configuration for usage instructions that may help identify the cause of the error.

To do so, follow the steps listed below.

  • The first step is to establish the application your web server is using.
  • To do so, look for a key file like the .htaccess file (Apache). However, if you are running on a shared host, you can locate the application root directory by inputting _ /home/public_html/. _ This will direct you to _ /home/public_html/.htaccess, _ where your .htaccess file is.
  • Proceed to open the .htaccess file in a text editor.
  • Find lines with Rewrite directives. This RewriteRule directs a browser URL request to the appropriate page when the URL matches your web server protocol.
  • However, if you notice any strange Rewrite directives, comment with the _ # _ prefix.
  • Restart your web server. This should solve the problem.

Undo Your Recent WordPress Updates

WordPress update can result in the Request Method’ POST’ Not Supported error, especially if the error shows up after your recent update. If this is the case, you may need to restore the previous WordPress version. However, before you restore the previous version, ensure you backup your website.

You can do so manually or use a plugin like WP Downgrade. However, the effective way to update is by using the plugin, which automates the process.

If this process doesn’t solve the error, you can restore your backup, re-update the website, and probably try a different method.

Debug Your Application Code

This method should be the last option when all the other methods have proven ineffective. Debugging your code or scripts will address the Request Method’ POST’ Not Supported error if the error generates from the WordPress installation custom code.

But before you do anything, back up your installation in a development area.

After backing up, proceed to debug the code. Note that this process will vary depending on the software and website. You need to follow the procedure step-by-step as it does not have a shortcut.

Proactively Monitor for Errors

Downtime is costly. In an ideal world, you should proactively monitor your sites to get alerted as soon as such error occurs, using Uptime Monitoring tools. Hyperping is an excellent way to keep an eye on your sites and stay alert. Setup takes roughly a couple of minutes:

  • Add sites you want to monitor. Hyperping will periodially ping your sites and instantly report any error
  • Setup alerts — Receive notifications via a plethora of channels: email, SMS, Slack, Teams, PagerDuty, OpsGenie, Telegram or Discord

Conclusion

The Request Method’ POST’ Not Supported error can emanate from several factors. However, regardless of the cause, you need to address the problem as soon as possible. Failure to do will cause a vast down track of visitors to your site, lowering your sales volume. Monitoring is essential to stay on top of downtime and fix errors as quick as possible.

Use the methods we have given in this article to address this issue effectively.

This the Item entity

{

    "fields": [
        {
            "fieldId": 1,
            "fieldName": "nombre",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldId": 2,
            "fieldName": "clave",
            "fieldType": "String",
            "fieldValidateRules": [
                "required",
                "maxlength"
            ],
            "fieldValidateRulesMaxlength": 20
        },
        {
            "fieldId": 3,
            "fieldName": "precio",
            "fieldType": "BigDecimal",
            "fieldValidateRules": [
                "required",
                "min"
            ],
            "fieldValidateRulesMin": 0
        },
        {
            "fieldId": 4,
            "fieldName": "status",
            "fieldType": "String",
            "fieldValidateRules": []
        }
    ],
    "changelogDate": "20151003200321",
    "dto": "no",
    "pagination": "pagination"
}

This is the Stock entity

{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "item",
            "otherEntityName": "item",
            "relationshipType": "many-to-one",
            "otherEntityField": "item"
        },
        {
            "relationshipId": 2,
            "relationshipName": "user",
            "otherEntityName": "user",
            "relationshipType": "many-to-one",
            "otherEntityField": "user"
        }
    ],
    "fields": [
        {
            "fieldId": 1,
            "fieldName": "cantidad",
            "fieldType": "Integer",
            "fieldValidateRules": [
                "required",
                "min"
            ],
            "fieldValidateRulesMin": 0
        },
        {
            "fieldId": 2,
            "fieldName": "tipoTransaccion",
            "fieldType": "String",
            "fieldValidateRules": [
                "required",
                "maxlength"
            ],
            "fieldValidateRulesMaxlength": "2"
        }
    ],
    "changelogDate": "20151003200614",
    "dto": "no",
    "pagination": "pagination"
}

Thanks!

First of all say apology to ask this repeated Question..

Actually in my spring Application i have user.jsp and professional.jsp

here is my User.jsp:

  <form:form action="profile/user" modelAttribute="profile">
    <div>
        <jsp:include page="professional.jsp"></jsp:include>
    </div>

</form:form>

And here is my professional.jsp:

   <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<fieldset id="profile_proffiesional">
    <form:form action="profile/proffiesional" modelAttribute="PROFESSIONAL" method="POST">
        <p>
            <label for="position">Position</label>
            <form:input path="position" tabindex="4" />
        </p>
        <p>
            <label for="location">Location</label>
            <form:input path="location" tabindex="5" />
        </p>
        <p>
            <label for="description">Description</label>
            <form:input path="description" tabindex="5" />
        </p>
        <p>
            <input type="submit" value="Add">
        </p>
    </form:form>
</fieldset>

And here is my Controller class:

    @Controller
@RequestMapping(value = "profile")
public class UserProfileController {

    @Autowired
    private UserService userService;

    @Autowired
    private SessionData sessionData;

    @RequestMapping(value = "user", method = RequestMethod.GET)
    public String user(Model model) throws Exception {
        model.addAttribute("PROFESSIONAL", new UserProfessionalForm());
        model.addAttribute("EDUCATIONAL", new UserEducationalForm());
        model.addAttribute("AWARDS", new UserAwardsForm());
        return "profile/user";
    }

    @RequestMapping(value = "proffessional", method = RequestMethod.POST)
    public @ResponseBody
    String forgotPassword(UserProfessionalForm professionalForm,
            BindingResult result, Model model) {

        UserProfileVO userProfileVO = new UserProfileVO();
        userProfileVO.setUser(sessionData.getUser());
        userService.saveUserProfile(userProfileVO);
        model.addAttribute("professional", professionalForm);
        return "Your Professional Details Updated";
    }
}

Problem is when we are Click Add button in professional.jsp, there is no response in server console but below warning message shown:

  29 Mar, 2013 1:03:51 PM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported
WARNING: Request method 'POST' not supported

Why this Warning coming? i’m already specified method=»POST»..

Please help..

Many errors can prompt a page in any search engine. The most common ones are the 404 Not Found Error and the 404 Not Supported Error. Yeah, once in a while, you might encounter this notification; the request method’ post’ is not supported. This prompt gives no one an option but to leave the page. Take it this way; the error message prompts in your website, yet you depend on these search engines to generate more traffic into your website. The results are annoying and hurt your business because you lose a chance to gain new customers.

But, what exactly does this request method ‘post’ is not supported mean? How do you get around this issue? Addressing this problem can be challenging. However, we have given the best way to address this error message whenever it pops on your page.

Read through to learn how to.

What Does the Request Method’ POST’ Not Supported Mean?

The Request Method’ POST’ Not Supported’ is an HTTP response status. The error prompt shows that a request to access your website has been sent from a web browser. Despite your web server receiving and recognizing the request, it cannot grant the requested site page access. This error is due to the unsupported HyperText Transfer Protocol (HTTP) method. This feature means that the browser requesting access to your site page cannot access it.

The specific browser your visitor is using will show an error page rather than the page they requested. Most browsers will display a 404 Not Allowed Error; this prompt is what your visitor will see on their browser pages. Such browsers include Firefox, Google Chrome, and Microsoft Edge.

This error page is one of the common errors visitors and web developers encounter once in a while. You might see your browser pages taking long to load, links breaking, and so on. As a Web developer, you should always address such issues almost immediately; otherwise, you’ll lose more visitors, resulting in a sales drop.

What Causes the Request Method ‘POST’ Not Supported Error?

The Request Method’ POST’ Not Supported error is caused by a mismatch of the web browser configuration and the browser’s URL format. In this case, the browser sends a URL request, the web server receives and recognizes the URL but cannot execute commands or grant access to the requested page. Despite the server recognizing the URL format, the target page does not support such format. The web server will send an error message to the browser, showing an error page.

What Format does the Request Method ‘POST’ Not Supported Error Display?

The Request Method’ POST’ Not Supported error can appear in different formats depending on the browser, Operating Systems, and web servers.

Below is how this error can appear on your browser.

  • HTTP 405 Error
  • HTTP 405 Method Not Allowed
  • 405 Not Allowed
  • HTTP Error 405 – Method Not Allowed
  • Method Not Allowed

No matter the format in which the error appears, you must immediately restore your browser. The process might be challenging, but we have swiftly helped you navigate the issue. Here’s is how to.

What Are the Best Methods to Solve the Request Method’ Post’ Not Supported Error?

Try the following methods to solve this error.

Confirm That Your Input URL Is Correct

The wrong URL is the primary cause of this error, as web servers prevent visitors from accessing the wrong pages. Therefore, you should check it to confirm that all is good. Be sure to confirm that your spelling is correct and that you’ve included all letters.

Confirm if You Have Database Changes

Plugins can modify database records under WordPress without notice. When you uninstall such plugins, they can’t revert the earlier changes; instead, they ignore them. This condition may result in Request Method’ POST’ Not Supported error when left unaddressed.

Therefore, you need to check your database to see the changes. You can do this by opening the database and going through the table to identify the plugins’ changes. If you find this process challenging, seek help from your web developer.

Check the Server’s Configuration

You should check your website server’s configuration for usage instructions that may help identify the cause of the error.

To do so, follow the steps listed below.

  • The first step is to establish the application your web server is using.
  • To do so, look for a key file like the .htaccess file (Apache). However, if you are running on a shared host, you can locate the application root directory by inputting _ /home/public_html/. _ This will direct you to _ /home/public_html/.htaccess, _ where your .htaccess file is.
  • Proceed to open the .htaccess file in a text editor.
  • Find lines with Rewrite directives. This RewriteRule directs a browser URL request to the appropriate page when the URL matches your web server protocol.
  • However, if you notice any strange Rewrite directives, comment with the _ # _ prefix.
  • Restart your web server. This should solve the problem.

Undo Your Recent WordPress Updates

WordPress update can result in the Request Method’ POST’ Not Supported error, especially if the error shows up after your recent update. If this is the case, you may need to restore the previous WordPress version. However, before you restore the previous version, ensure you backup your website.

You can do so manually or use a plugin like WP Downgrade. However, the effective way to update is by using the plugin, which automates the process.

If this process doesn’t solve the error, you can restore your backup, re-update the website, and probably try a different method.

Debug Your Application Code

This method should be the last option when all the other methods have proven ineffective. Debugging your code or scripts will address the Request Method’ POST’ Not Supported error if the error generates from the WordPress installation custom code.

But before you do anything, back up your installation in a development area.

After backing up, proceed to debug the code. Note that this process will vary depending on the software and website. You need to follow the procedure step-by-step as it does not have a shortcut.

Conclusion

The Request Method’ POST’ Not Supported error can emanate from several factors. However, regardless of the cause, you need to address the problem as soon as possible. Failure to do will cause a vast down track of visitors to your site, lowering your sales volume.

Use the methods we have given in this article to address this issue effectively.

This the Item entity

{

    "fields": [
        {
            "fieldId": 1,
            "fieldName": "nombre",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldId": 2,
            "fieldName": "clave",
            "fieldType": "String",
            "fieldValidateRules": [
                "required",
                "maxlength"
            ],
            "fieldValidateRulesMaxlength": 20
        },
        {
            "fieldId": 3,
            "fieldName": "precio",
            "fieldType": "BigDecimal",
            "fieldValidateRules": [
                "required",
                "min"
            ],
            "fieldValidateRulesMin": 0
        },
        {
            "fieldId": 4,
            "fieldName": "status",
            "fieldType": "String",
            "fieldValidateRules": []
        }
    ],
    "changelogDate": "20151003200321",
    "dto": "no",
    "pagination": "pagination"
}

This is the Stock entity

{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "item",
            "otherEntityName": "item",
            "relationshipType": "many-to-one",
            "otherEntityField": "item"
        },
        {
            "relationshipId": 2,
            "relationshipName": "user",
            "otherEntityName": "user",
            "relationshipType": "many-to-one",
            "otherEntityField": "user"
        }
    ],
    "fields": [
        {
            "fieldId": 1,
            "fieldName": "cantidad",
            "fieldType": "Integer",
            "fieldValidateRules": [
                "required",
                "min"
            ],
            "fieldValidateRulesMin": 0
        },
        {
            "fieldId": 2,
            "fieldName": "tipoTransaccion",
            "fieldType": "String",
            "fieldValidateRules": [
                "required",
                "maxlength"
            ],
            "fieldValidateRulesMaxlength": "2"
        }
    ],
    "changelogDate": "20151003200614",
    "dto": "no",
    "pagination": "pagination"
}

Thanks!

Simple Spring Boot POST request not working and returns:
«Request method ‘POST’ not supported» error message.

The code itself looks fine to me, but I’m not so sure about the pom.xml.
If the problem relies in the pom.xml, then this case is hopeless since I don’t even know what all those dependencies do nor why there are duplicates.

Here is my controller class:

@Controller
public class StudentController {

@Autowired
private StudentRepository studentRepository;


@GetMapping("/")
public String list(Model model) {
    model.addAttribute("students", studentRepository.findAll());
    return "index";
}


@PostMapping("/")
public String add(@RequestParam String name) {
    Student student = new Student(name);
    this.studentRepository.save(student);
    return "redirect:/";
}
}

Index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Test</title>
</head>
<body>
    <p>List all students </p>

    <p>Add a Student</p>

 <form th:action="@{/}" method="POST">
    <input type="text" name="name"/>
    <input type="submit"/>
</form>

<p>Students</p>

<p th:each="student : ${students}">
    <span th:text="${student.name}">student name</span>
</p>

</body>
</html>

Pom.xml

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
 <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>        
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>

    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-junit</artifactId>
        <version>3.7.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-assertj</artifactId>
        <version>3.7.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
    </dependency>  

</dependencies>

<build>
    <plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    <resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
    </resources>
</build>
</project>

The code is supposed to add a student to studentRepository and redirect back to index.html and display the added student instantly.

Error Message from soapUI:

"timestamp": "2019-05-24T09:02:36.088+0000",
"status": 405,
"error": "Method Not Allowed",
"message": "Request method 'POST' not supported",
"trace": "org.springframework.web.HttpRequestMethodNotSupportedException: 
"path": "/"

Full trace:

> "trace":
> "org.springframework.web.HttpRequestMethodNotSupportedException: 
> Request method 'POST' not supportedrntat 
> org.springframework.web.servlet.support.WebContentGenerator.checkRequest(WebContentGenerator.java:380)rntat
> org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:163)rntat
> org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52)rntat
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)rntat
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)rntat
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)rntat
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)rntat
> javax.servlet.http.HttpServlet.service(HttpServlet.java:660)rntat
> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)rntat
> javax.servlet.http.HttpServlet.service(HttpServlet.java:741)rntat
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)rntat
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)rntat
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)rntat
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat
> org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)rntat
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat
> org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)rntat
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat
> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)rntat
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)rntat
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)rntat
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)rntat
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)rntat
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)rntat
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)rntat
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)rntat
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)rntat
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)rntat
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)rntat
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)rntat
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)rntat
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)rntat
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)rntat
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rntat
> java.lang.Thread.run(Thread.java:745)rn"

application.properties

server.port=8083
[email protected]@
spring.datasource.url=jdbc:h2:file:./database;create=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect

Tutorial which is working fine:

Controller class

@Controller
public class ItemDatabaseController {

@Autowired
private ItemRepository itemRepository;

@GetMapping("/")
public String list(Model model) {
    model.addAttribute("items", this.itemRepository.findAll());
    return "index";
}

@PostMapping("/")
public String add(@RequestParam String name) {
    this.itemRepository.save(new Item(name));
    return "redirect:/";
}

}

index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Item Database</title>
</head>

<body>
    <h1>Item Database</h1>

    <table>
        <tr>
            <th>Items</th>
        </tr>

        <tr th:each="item : ${items}">
            <td th:text="${item.name}">Item name</td>
        </tr>
    </table>

    <h2>Add an item</h2>

    <form th:action="@{/}" method="POST">
        <span>Name:</span>
        <input type="text" name="name"/>
        <input type="submit" value="Add!"/>
    </form>
</body>
</html>

pom.xml

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.3.RELEASE</version>
    <relativePath/>
</parent>

<dependencies>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>        
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>

    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-junit</artifactId>
        <version>3.7.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-assertj</artifactId>
        <version>3.7.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
    </dependency>  
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

These two are virtually the same, except this tutorial was downloaded and my own project was created in Eclipse as a Spring Boot: Spring Starter Project. Which is an Eclipse plugin.

Помогите пожалуйста решить проблему

jsp

    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ page contentType="text/html;charset=UTF-8" language="java" %>

    <html>
    <head>
         <title>Title</title>
    </head>

<body>

    <c:if test="${currentRoom.getLight()}">
        <form method="post" action="/room/allroom/">
            <input type="radio" name="status" value="turnOff">
            <button type="submit">Выключить</button>
        </form>
    </c:if>

    <c:if test="${!currentRoom.getLight()}">
        <form method="post" action="/room/allroom/">
            <input type="radio" name="status" value="turnOn">
            <button type="submit">Включить</button>
        </form>
    </c:if>
</body>

Controller

@Controller
@RequestMapping(path = "/room")
public class RoomController {
@GetMapping(path = "allroom/{roomNumber}")
    public ModelAndView getRoomById(@PathVariable("roomNumber") Integer roomNumber, ModelAndView modelAndView, HttpServletRequest httpServletRequest){
        modelAndView.setViewName("currentRoom");
        List<Room> roomList = roomService.allListRooms();
        Room room = roomList.get(roomNumber);
        httpServletRequest.getSession().setAttribute("currentRoom", room);
        return modelAndView;
    }

    @PostMapping(path = "allroom/{roomNumber}")
    public ModelAndView light(@PathVariable("roomNumber") Integer roomNumber, @RequestParam("status") String status, ModelAndView modelAndView, HttpServletRequest httpServletRequest){
        modelAndView.setViewName("currentRoom");
        if(status.equals("turnOn")){
            roomService.lightOn(roomNumber);
            return modelAndView;
        }
        if(status.equals("turnOff")){
            roomService.lightOff(roomNumber);
            return modelAndView;
        }
        return modelAndView;
    }

Ошибка:
Message Request method ‘POST’ not supported

Description The method received in the request-line is known by the origin server but not supported by the target resource.

Skip to content

I am new with springMVC technology. When I create my first form with post method, I got Error 405 (Request method ‘POST’ not supported).

error post method

After some googling, I found that the error was because I use csrf on my web application. I should add some code for token on my action form like “${_csrf.parameterName}=${_csrf.token}”. So, here are my code became:

SpringSecurity.xml

<beans:beans xmlns="http://www.springframework.org/schema/security"
	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
	http://www.springframework.org/schema/security
	http://www.springframework.org/schema/security/spring-security-3.2.xsd">

	<!-- enable use-expressions -->
    <http auto-config="true" use-expressions="true">
            <intercept-url pattern="/" access="isAuthenticated()" />
            <intercept-url pattern="/images/**" access="permitAll"/>
            <intercept-url pattern="/home" access="isAuthenticated()" />
            <!-- access denied page -->
            <access-denied-handler error-page="/403" />
            <form-login 
                login-page="/login" 
                default-target-url="/home"
                authentication-failure-url="/login?error" 
                username-parameter="username"
                password-parameter="password" />
            <logout logout-success-url="/login?logout" />
            <!-- enable csrf protection -->
            <csrf />
    </http>

	<authentication-manager>
		<authentication-provider user-service-ref="MyUserDetailsService" >
			<password-encoder hash="bcrypt" />    
		</authentication-provider>
	</authentication-manager>

</beans:beans>

My controller

@RequestMapping(value="admin/save", method = RequestMethod.POST)
    public String save(ModelMap model,
            @RequestParam String name,
            @RequestParam String username,
            @RequestParam String password,
            @RequestParam String[] userRoles){
        
        Users user = new Users();
        user.setName(name);
        user.setUsername(username);
        user.setEnable(new BigDecimal(1));
        BCryptPasswordEncoder pwdEncoder = new BCryptPasswordEncoder();        
        user.setPassword(pwdEncoder.encode(password));
        
        try {
            userService.saveOrUpdate(user);
            saveAction(BaseController.SAVE_OR_UPDATE_USER + " " + user.getUsername());
        } catch (Exception e) {
            System.out.println("failed to save user caused " + e.getMessage());
        }
        
        //some code to process another things
        
        model.put(PARAM_USERNAME, BaseController.getNameUser());
        return "redirect:/admin";
        
    }

My JSP

                <form role="form" action="${baseURL}/admin/save?${_csrf.parameterName}=${_csrf.token}" method="POST" id="edituser">
                    <div class="form-group">
                        <label>Name</label>
                        <input class="form-control" name="name" id="name" placeholder="input name here" type="text" required="true" value="${usernm.name}"/>
                    </div>
                    <div class="form-group">
                        <label>Username</label>
                        <input class="form-control" name="username" id="username" placeholder="input username here" type="text"  required="true" value="${usernm.username}"/>
                    </div>
                    <div class="form-group">
                        <label>Password</label>
                        <input class="form-control" name="password" id="password" placeholder="input password here" type="password" value="${usernm.password}" required="true"/>
                    </div>
                    <div class="form-group">
                        <label>Role</label>
                        <span id="errorMsg" class="msg"></span>
                        <div class="checkbox" style="width: 200px; height: 20px;">
                            <label>
                                <input name="userRoles" type="checkbox" value="ROLE_ADMIN" <c:if test="${hasAdmin != null && hasAdmin}">checked="true"</c:if> >Admin
                                </label>
                            </div>
                            <!-- some roles option -->
                        </div>
                        <button type="submit" class="btn btn-default" id="btnSubmit">Submit</button>&nbsp;&nbsp;&nbsp;<input type="button" onclick="location.href = '${baseURL}/admin'" class="btn btn-primary" value="Cancel"/>
                </form>
           

Hope this simple article can help some of you 🙂

Я получаю эту ошибку: HTTP Status 405 - Request method 'POST' not supported

То, что я пытаюсь сделать, это создать форму с раскрывающимся списком, который заполняется на основе другого значения, выбранного в другом раскрывающемся списке. Например, когда я выбираю имя в customerName упаковать onChange должна быть запущена функция на странице .jsp, а отправленная страница затем снова загружена с соответствующими значениями в customerCountry пунктом.

однако я получаю эту ошибку HTTP Status 405. Я искал в Интернете решение, но не смог найти ничего, что помогло бы. Вот соответствующие части моего кода:

часть jsp-страницы

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Insert title here</title>
            <style>
            .error { color: red; }
            </style>

        <script>
            function repopulate(){  
                document.deliveryForm.submit();
            }

            function setFalse(){
                document.getElementById("hasId").value ="false";
                document.deliveryForm.submit();
                // document.submitForm.submit(); (This was causing the error)

            }
        </script>

    </head>
    <body>

        <h1>Create New Delivery</h1>

        <c:url var="saveUrl" value="/test/delivery/add" />
        <form:form modelAttribute="deliveryDtoAttribute" method="POST" action="${saveUrl}" name="deliveryForm">
            <table>


                <tr>
                    <td><form:hidden id="hasId" path="hasCustomerName" value="true"/></td>
                </tr>

                <tr>
                    <td>Customer Name</td>
                    <td><form:select path="customerName" onChange="repopulate()">
                        <form:option value="" label="--- Select ---" />
                        <form:options items="${customerNameList}" />
                        </form:select>
                    </td>
                    <td><form:errors path="customerName" cssClass="error" /></td>
                </tr>

                <tr>
                    <td>Customer Country</td>
                    <td><form:select path="customerCountry">
                        <form:option value="" label="--- Select ---" />
                        <form:options items="${customerCountryList}" />
                        </form:select>
                    </td>
                    <td><form:errors path="customerCountry" cssClass="error" /></td>
                </tr>

        </form:form>

        <form:form name="submitForm">
        <input type="button" value="Save" onClick="setFalse()"/>
        </form:form>

    </body>
</html>

часть контроллера:

@RequestMapping(value = "/add", method = RequestMethod.GET)
    public String getDelivery(ModelMap model) {
        DeliveryDto deliveryDto = new DeliveryDto();

        model.addAttribute("deliveryDtoAttribute", deliveryDto);
        model.addAttribute("customerNameList",
                customerService.listAllCustomerNames());
        model.addAttribute("customerCountryList", customerService
                    .listAllCustomerCountries(deliveryDto.getCustomerName()));
        return "new-delivery";
    }

    // I want to enter this method if hasId=true which means that a value in the CustomerName 
    // drop down list was selected. This should set the CountryList to the corresponding values 
    // from the database. I want this post method to be triggered by the onChange in the jsp page

    @RequestMapping(value = "/add", method = RequestMethod.POST, params="hasCustomerName=true")
    public String postDelivery(
            @ModelAttribute("deliveryDtoAttribute") DeliveryDto deliveryDto,
            BindingResult result, ModelMap model) {


            model.addAttribute("deliveryDtoAttribute", deliveryDto);

            model.addAttribute("customerNameList",
                    customerService.listAllCustomerNames());
            model.addAttribute("customerCountryList", customerService
                    .listAllCustomerCountries(deliveryDto.getCustomerName()));

            return "new-delivery";
    }

    // This next post method should only be entered if the save button is hit in the jsp page

    @RequestMapping(value = "/add", method = RequestMethod.POST, params="hasCustomerName=false")
    public String postDelivery2(
            @ModelAttribute("deliveryDtoAttribute") @Valid DeliveryDto deliveryDto,
            BindingResult result, ModelMap model) {

        if (result.hasErrors()) {

            model.addAttribute("deliveryDtoAttribute", deliveryDto);

            model.addAttribute("customerNameList",
                    customerService.listAllCustomerNames());
            model.addAttribute("customerCountryList", customerService
                    .listAllCustomerCountries(deliveryDto.getCustomerName()));

            return "new-delivery";
        } else {

            Delivery delivery = new Delivery();

            //Setters to set delivery values

            return "redirect:/mis/home";
        }

    }

Почему я получаю эту ошибку? Любая помощь приветствуется! Спасибо

EDIT: Изменено hasId в hasCustomerName. я все еще получаю HTTP Status 405 - Request method 'POST' not supported ошибка однако.

EDIT2: Закомментировал строку в setFalse функция, вызвавшая ошибку

// Д

  • Ошибка request failed with status code 403
  • Ошибка rendering thread exception fatal error
  • Ошибка rendering error 0x00000000 world of tanks blitz
  • Ошибка rendering error 0x00000000 failedtocreatedevice program will terminate windows 7
  • Ошибка render creation error морровинд