【问题标题】:Correct HTML Component with the name must be given correctly必须正确给出具有名称的正确 HTML 组件
【发布时间】:2022-06-25 14:07:30
【问题描述】:

我收到错误喜欢
失败 1

正确的 HTML 组件的名称 'userName/contactNumber/emailId/confirmEmailId/status/submit' 必须正确填写

失败 2

名称为“userName”的正确 HTML 组件必须与适当的约束一起使用

如何解决?

  <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
    <%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    
    <body style="background-color: lavender">
        <center>
            <h1>Welcome to Online Help Services</h1>
    
            <form:form action="/register" method="post" modelAttribute="register">
                <table>
                    <tr>
                        <td>UserName:</td>
                        <td><form:input path="userName" id="userName" /></td>
                        <td><form:errors path="userName" /></td>
                    </tr>
                    <tr>
                        <td>Contact Number</td>
                        <td><form:input path="contactNumber" id="contactNumber" /></td>
                        <td><form:errors path="contactNumber" /></td>
                    </tr>
                    <tr>
                        <td>Email Id</td>
                        <td><form:input path="emailId" id="emailId" /></td>
                        <td><form:errors path="emailId" /></td>
                    </tr>
                    <tr>
                        <td>Confirm Email Id</td>
                        <td><form:input path="confirmEmailId" id="confirmEmailId" /></td>
                        <td><form:errors path="confirmEmailId" /></td>
                    </tr>
                    <tr>
                        <td><form:checkbox path="status" id="status" /></td>
                        <td>I agree</td>
                        <td><form:errors path="status" /></td>
                    </tr>
                    <tr>
                        <td><input type="submit" value="Register" name="submit" /></td>
                        <td><input type="reset" value="Cancel" /></td>
                    </tr>
                </table>
            </form:form>
        </center>
            
    </body>
    </html>

【问题讨论】:

    标签: spring-boot spring-mvc jsp


    【解决方案1】:

    很可能,错误在于您的application.properties 文件。为 spring mvc 视图提供正确的前缀和后缀。

    【讨论】:

    • 这可以作为评论而不是答案。
    • 我的“添加评论”被禁用,这就是我选择这种方式的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-18
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 2011-02-21
    • 2011-12-14
    • 2020-01-18
    相关资源
    最近更新 更多