English 中文(简体)
jstl 输出不工作
原标题:jstl output doesn t work

我正在设法使应用程序(为Tomcat 5.5开发的)与Tomcat 7兼容(7.0.27)。

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

在我的WEB-INF/web.xml文件中(以前使用了2.4版)。

例如.jsp 文件:

%@page
   language="java"
   pageEncoding="utf-8"
   contentType="text/html;charset=utf-8"
   buffer="none"
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="uri:path-to-layout/layout" prefix="layout" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:bundle basename="com.path.to.resources.Labels">

.

<td><input
name="j_username"
id="j_username" 
maxlength="30" 
accesskey="2" 
type="text"
style="width: 150px;"
value="<c:out value="${pageContext.request.remoteUser}" default="" />" /></td>

而不是预期产出,我收到:

${pageContext.request.remoteUser}

作为文本字段中的值。

我使用JSTL 1.2.1, Tomcat 7.0.27, JSP 2.2. 代码汇编。 当我将Web.xml中的网络应用版本从3.0 改为 2.4时,它不会直接输出这些值(尽管还有其他问题迫使我使用3.0 版本)。 任何想法都可能导致这一问题?

最佳回答

你提到你使用JSTL 1.2.1, 我猜是以下那些被从玻璃鱼服务器上劫持的人:

  • javax.servlet.jsp.jstl-1.2.1.jar
  • javax.servlet.jsp.jstl-api-1.2.1.jar

然而,根据评论,在/WEB-INF/lib 中的117个档案中,似乎还有旧的JSTL1.0/1.1图书馆:

  • jstl.jar
  • standard.jar

这只会造成冲突。 ` 强势'撤回 < / 强势'。

问题回答

您需要为 c:out 使用单引号, 否则您将结束 value 标签中 put 标签的 属性。 代之以 :

<td><input name="j_username" id="j_username" maxlength="30" accesskey="2"
     type="text" style="width: 150px;" 
     value="<c:out value= ${pageContext.request.remoteUser}  default=   />" /></td>




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...