2016-06-21 48 views
0

간단한 프로젝트를 만들려고합니다. Eclipse를 통해 tomcat7. 여기 내 JSP 페이지의 코드입니다 : 여기

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
    <body> 
     User ID: ${user.userId}<br /> 
     Username: ${user.username} (${user.username.length()} characters)<br /> 
     Full Name: ${fn:escapeXml(user.lastName) += ', ' 
      += fn:escapeXml(user.firstName)} 
     <br /><br /> 
     <b>Permissions (${fn:length(user.permissions)})</b><br /> 
     User: ${user.permissions["user"]}<br /> 
     Moderator: ${user.permissions["moderator"]}<br /> 
     Administrator: ${user.permissions["admin"]}<br /> 
    </body> 
</html> 

브라우저 창에서 결과입니다 :

org.apache.jasper.JasperException: javax.el.ELException: Failed to parse the expression [${fn:escapeXml(user.lastName) += ', ' 
     += fn:escapeXml(user.firstName)}] 
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) 
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
ProfileServlet.doGet(ProfileServlet.java:46) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:620) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 

root cause 

javax.el.ELException: Failed to parse the expression [${fn:escapeXml(user.lastName) += ', ' 
     += fn:escapeXml(user.firstName)}] 
org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:145) 
org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:171) 
org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:216) 
org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:66) 
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943) 
org.apache.jsp.WEB_002dINF.jsp.view.profile_jsp._jspService(profile_jsp.java:96) 
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) 
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
ProfileServlet.doGet(ProfileServlet.java:46) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:620) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 

    root cause 

    org.apache.el.parser.ParseException: Encountered " <ILLEGAL_CHARACTER> "= "" at line 1, column 32. 

대상으로 런타임을 설정 (tomcat7는). 아마도 내 tomcat7/lib 디렉토리에 잘못된 것이 있습니까?

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 

"보통"JSTL 태그는 잘 작동 (모든 JSP를의 헤더이다) 또한 여기

이 base.jspf에서 수입이다 (JSTL 1.2 항아리 폴더에 있습니다). 기능

+2

왜'+ ='입니까? 당신은 간단한'+'를 시도 했습니까? 'fn : escapeXml (user.lastName + ','+ user.firstName)'은 더 쉽게 읽을 수있게 해줍니다. IMHO –

+0

예. 그러나 같은 메시지가 여전히 발생합니다. 예, 접근법이 더 읽기 쉽다고 생각합니다. 하지만 lib 폴더의 jasper * 파일에 아마도 – kurumkan

+0

책의 튜토리얼에 문제가 있습니까? 무엇을 해야할지 모르겠다. – kurumkan

답변

2

에 문제는이 같은 core:out를 사용해보십시오 :

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
    User ID: <c:out value="${user.userId}" /> 
    <br /> Username: <c:out value="${user.username}" /> (<c:out value="${user.username.length}" /> characters) 
    <br /> Full Name: <c:out value="${user.lastName}" />, <c:out value="${user.firstName}" /> 
    <br /> 
    <br /> 
    <b>Permissions (${fn:length(user.permissions)})</b> 
    <br /> User: <c:out value="${user.permissions.user}" /> 
    <br /> Moderator: <c:out value="${user.permissions.moderator}" /> 
    <br /> Administrator: <c:out value="${user.permissions.admin}" /> 
    <br /> 
</body> 
</html> 

그것은 나를 위해 잘 작동하고 기본적으로 XML을 탈출.