2017-04-12 8 views
0

설명 할 수없는 이상한 문제가 있습니다. 나는 플레이 프레임 워크를 사용하고 있는데 아래의보기를 실행하려고하면 아래의 양식 작업을 반복 할 때만 작동합니다 ... 작동하지만 올바르게 작동하지 않습니다. 누구든지 설명이나 수정을 도울 수 있다면 고맙습니다.스칼라 플레이 양식

@(errorMessage: String = "")(implicit messages: Messages) 

@helper.form(routes.ApplicationHomeController.login) { 
    @main(title = messages("single.title")) { 
     <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet" type="text/css"> 
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
     <div id="userbox"> 
      <form action="@{routes.ApplicationController.doLogin()}" method="post"></form> 

      <form action="@{routes.ApplicationController.doLogin()}" method="post"> 
       <div style="color: red">@errorMessage</div> 
       <h1 id="logintxt" style="background-color: rgb(11, 146, 9); 
          background-position: initial; 
          background-repeat: initial;">Driver Service <b>ß</b>eta</h1> 

       <div id="submit_giff" style="display: none;"> 
        <hi> Authenticating: <img src="/assets/images/loader-bar.gif" align="absmiddle"> </hi> 
       </div> 
       <input id="name" name="userName" placeholder="Username" style="opacity: 1; 
          background-color: rgb(255, 255, 255); 
          background-position: initial; 
          background-repeat: initial;"> 
       <input id="pass" name="password" type="password" placeholder="Password" style="opacity: 1; 
          background-color: rgb(255, 255, 255); 
          background-position: initial; 
          background-repeat: initial;"> 

       <p id="namealert" style="display: none; 
          opacity: 1;">Username:</p> 
       <p id="passal" style="display: none; 
          opacity: 1;">Password:</p> 
       <input id="loginbtn" style="opacity: 0.2; 
          cursor: default;" type="submit" value="Login"> 
      </form> 
     </div> 
     <script src="/assets/javascripts/login.js"></script> 
    } 
} 

답변

2

두 가지 즉각적인 관찰.

하나 : @helper.form(...)은 궁극적으로 생성되는 HTML에 <form> 요소를 쓸 것입니다. 그런 다음 다른 문자 <form>안에 중첩 된 첫 번째 형태 인이 포함됩니다. Nested forms are invalid HTML. 하나의 양식을 routes.ApplicationController.doLogin에 제출하고 다른 양식을 routes.ApplicationController.login에 제출하십시오. 브라우저에서 실제로 제출할 브라우저를 누가 알 수 있습니까? 중첩 된 양식이 유효하지 않기 때문에 실제로 예측할 수 없습니다.

두 : @main(...)보기가 내에서@helper.form(...) 내에서 중첩되어 있습니다. 기본보기에 <html>...</html>이 포함되어 있다고 가정합니다. 그러면 <form> 요소 인 으로 시작하는<html> 요소로 시작하는 HTML이 생성됩니다. 이것은 무효하게 무효 마크 업입니다.

내 추측은 이러한 문제 중 하나 이상이 모두 문제가되는 것입니다.

생성 된 HTML을 가져 와서 https://validator.nu/과 같은 HTML 검사기를 통해 실행 해보십시오. 검사기가 발견 한 모든 문제를 수정하고 양식을 중첩하지 않으며 로그인 양식이 실제로 제출해야하는 경로를 결정하십시오.