jsp页面中
String s="<h1>This is a heading</h1>"
out.println(s);
输出的是:this is a heading而不是<h1>This is a heading</h1>,怎么让它<h1>This is a heading</h1>????
String s="<h1>This is a heading</h1>"
out.println(s);
输出的是:this is a heading而不是<h1>This is a heading</h1>,怎么让它<h1>This is a heading</h1>????
解决方案 »
- struts2,启动时报错!已经找了一早上了,在线等待!
- 几个Web开发中的通用模块共享
- 使用commons-fileupload时,如何改变上传文件名称
- 混IT30岁没人要了?
- 请问这里的3个gb2312分别在那里起作用
- applet在网页上不能运行,提示 CLASS AAA NOT FOUND
- html和servlet的整合问题(在线等问题解决马上结帖)
- 看看这个错误!
- 高手请进!!请问在jdk1.3.1中有没有JdbcOdbcDriver?是不是没有象jdk1.4那样的java plug in?
- 为什么我的servlet程序不能运行?
- struts2 导出excel并保存到WebRoot下
- DIV的层的问题
string = string.replaceAll("&", "&");
string = string.replaceAll("<", "<");
string = string.replaceAll(">", ">");
string = string.replaceAll("\"", """);
string = string.replaceAll("'", "'"); return string;
}
应该可以,我试过了
out.println("<</<>h1>1111<</<>/h1>");
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
</head>
<%
String s="<</<>h1>This is a heading<</<>/h1>";
%>
<body>
<%=s %>
</body>
</html>
struts2的话:<s:property value="b" escape="true"/> 。前提是你把要输出的东西扔request里了