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"

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!

I have just started learning Java Spring Boot for REST API development. With below code, GET method is working fine but POST doesn’t.

@RestController
@RequestMapping("/api/users")
public class UsersController {

    @Autowired
    private UserRepository userRepository;

    @RequestMapping(method = RequestMethod.GET)
    public List<User> getAll() {
        return userRepository.findAll();
    }

    @RequestMapping(method = RequestMethod.POST)
    public String saveUser() {
        return "Saved";
    }

}

Tested POST method in Postman app using Content-Type as application/json

Error,

{
    "timestamp": 1497116929266,
    "status": 405,
    "error": "Method Not Allowed",
    "exception": "org.springframework.web.HttpRequestMethodNotSupportedException",
    "message": "Request method 'POST' not supported",
    "path": "/api/users/"
}

In the log I can see,

s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/users],methods=[POST]}" onto public java.lang.String com.betasquirrel.controller.UsersController.saveUser()
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/users],methods=[GET]}" onto public java.util.List<com.betasquirrel.model.User> com.betasquirrel.controller.UsersController.getAll()
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

Java and springboot version for maven,

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

<properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <java.version>1.8</java.version>
</properties>

I have just started learning Java Spring Boot for REST API development. With below code, GET method is working fine but POST doesn’t.

@RestController
@RequestMapping("/api/users")
public class UsersController {

    @Autowired
    private UserRepository userRepository;

    @RequestMapping(method = RequestMethod.GET)
    public List<User> getAll() {
        return userRepository.findAll();
    }

    @RequestMapping(method = RequestMethod.POST)
    public String saveUser() {
        return "Saved";
    }

}

Tested POST method in Postman app using Content-Type as application/json

Error,

{
    "timestamp": 1497116929266,
    "status": 405,
    "error": "Method Not Allowed",
    "exception": "org.springframework.web.HttpRequestMethodNotSupportedException",
    "message": "Request method 'POST' not supported",
    "path": "/api/users/"
}

In the log I can see,

s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/users],methods=[POST]}" onto public java.lang.String com.betasquirrel.controller.UsersController.saveUser()
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/users],methods=[GET]}" onto public java.util.List<com.betasquirrel.model.User> com.betasquirrel.controller.UsersController.getAll()
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

Java and springboot version for maven,

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

<properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <java.version>1.8</java.version>
</properties>

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 🙂

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.

Понравилась статья? Поделить с друзьями:
  • Request mespilock failed ошибка
  • Request header or cookie too large как исправить ошибку
  • Request failed with status code 500 росреестр ошибка
  • Request failed internal server error 500 перевод
  • Request failed error reading the headers