在JSP中不断收到form:form标记错误

时间:2019-02-24 21:31:50

标签: html spring spring-mvc jsp model-view-controller

我不断收到错误消息,指出“文本/格式无效:form:form” “缺少form:form的结束标记” 和未知标记形式:form

   <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
 <!DOCTYPE html>
 <html>
 <head>
<meta charset="UTF-8">
 <form action ="some.jsp" class="form">



 <title>choose a country</title>
 </head>
  <body>
 <h1>choose your next destination</h1>
 <!DOCTYPE html>
  <html>
 <head>
  <meta name="viewport" content="width=device-width, initial-     scale=1.0">
 <style>
 * {
   box-sizing: border-box;
 }




  .autocomplete {
   position: relative;
   display: inline-block;
  }

  input {
   border: 1px solid transparent;
   background-color: #f1f1f1;
   padding: 10px;
   font-size: 16px;
 }

  input[type=text] {
    background-color: #f1f1f1;
   width: 100%;
  }

 input[type=submit] {
 background-color: DodgerBlue;
  color: #fff;
 cursor: pointer;
  }

  .autocomplete-items {
   position: centre;
   border: 1px solid #d4d4d4;
   border-bottom: none;
   border-top: none;
    z-index: 99;

    top: 100%;
    left: 0;
    right: 0;
  }

   .autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    background-color: #fff; 
    border-bottom: 1px solid #d4d4d4; 
  }


    .autocomplete-items div:hover {
     background-color: #e9e9e9; 
    }


    .autocomplete-active {
     background-color: DodgerBlue !important; 
     color: #ffffff; 
   }
  </style>
   </head>     
   <body>

    <h2>Travel the world</h2>

   <p>choose a country you'd like to go</p>


     <form:form method = "GET"  action=addcountry/country/ model attribute = "model" autocomplete="off">
      <div class="autocomplete" style="width:300px;">
        <input id="myInput" type="text" name="myCountry" placeholder="Country">
     </div>
     <input type=submit value ="lets go" class="btn btn-default"/>

  </form>
 <script>

我遇到的问题是什么?以前不存在,现在问题似乎不会消失。是什么导致此错误,我该如何解决? 谢谢!

1 个答案:

答案 0 :(得分:1)

您必须做的事情:

  1. 在您的JSP文件中添加<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>(可能在文件顶部)。
  2. 使用</form:form>而不是HTML </form>关闭Spring表单标签