리프트 스 니펫 : 프리픽스가 네임 스페이스에 바인딩되지 않습니다

StackOverflow https://stackoverflow.com/questions/1019599

  •  06-07-2019
  •  | 
  •  

문제

나는 방금 Lift와 Scala로 시작하고 내가 정말로 이해하지 못하는 문제가 있습니다.

폴링 index.html이 있습니다

<html>
<head><title>title</title></head>
<body>
    <table>
        <lift:Members.list>
            <tr>
                <td><m:nick/></td>
            </tr>
        </lift:Members.list>
    </table>
</body>
</html>

그리고 다음 스 니펫 :

class Members {
  def list(xhtml: NodeSeq) =
  Member.findAll.flatMap(member => bind("m",xhtml
                                       ,"nick" -> member.nickName
    ))
}  

어떤 이유로 다음 오류가 발생합니다. 나는 많은 것을 시도했지만 그것을 작동시킬 수는 없습니다. 뭐가 문제 야?

XML Parsing Error: prefix not bound to a namespace
Location: http://localhost:8080/hazardlift-1.0-SNAPSHOT/
Line Number 8, Column 25:<td><m:nick></m:nick></td>
-----------------------------^
도움이 되었습니까?

해결책

리프트는 반환 가치를 처리하는 방법을 얻지 못할 수도 있습니다. ReturnType로 지정하여 NodeseQ로 암시 적 변환을 강요하십시오.

....
def list(xhtml: NodeSeq) : NodeSeq = 
....

다른 팁

방금이 오류의 또 다른 원인 인 해결되지 않은 태그를 발견했습니다.

나는이 HTML을 가지고 있었다 :

<div >
    <h3>Request Information</h3>

    <lift:DetailedRequestData.renderContent>
        <f:rowTag></f:rowTag>
    </lift:DetailedRequestData.renderContent>
</div>

나는 이것을 위해 이것을 썼다 renderContent:

def renderContent(ns: NodeSeq): NodeSeq = {
  val key = beginTrans(DisplayData.logger)
  var result = ns

  try {
    var requestID = DisplayData.getParameter("request")
    bind("f", ns, "rowTag" -> <p>Request ID: {requestID}</p>)
  }
  catch {
    case t: Throwable => DisplayData.logger.error("[DetailedRequestData$.renderContent] ", t)
  }

  endTrans(DisplayData.logger, key)
  result
}

나는 결과를 할당하지 않았기 때문에 bind 에게 result, 나는 수정되지 않은 것을 반환했다 NodeSeq 그리고 똑같이 얻었습니다 prefix not bound to a namespace 오류. 하나의 진술 변경 :

    result = bind("f", ns, "rowTag" -> <p>Request ID: {requestID}</p>)

그렇습니다. 이것은 내 자신의 멍청한 잘못 이었지만 여기서 문제를 문서화함으로써 다른 사람이 같은 문제를 겪지 않고 이유를 모르기를 바랍니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top