jsp页面 URL传中文参数到Action里面出现乱码
解决方法:
第一种:在Action中用 new String(str.getBytes("ISO8859_1"), "UTF8"),进行转码,因为传递的时候,中文默人的是ISO8859_1
第二种:可通过配置TOMCAT来解决此问题,具体解决方法如下:在tomcat的server.xml里,找到<Connector port="8080" useBodyEncodingForURI="true" URIEncoding="utf-8">
其中是修改useBodyEncodingForURI="true" URIEncoding="utf-8" 其方法是防止在url中出现乱码
然后在每个Jsp页面添加如下代码
<%@ page pageEncoding=” utf-8″%>
<%@ page contentType=”text/html;charset= utf-8″%>
<%request.setCharacterEncoding(” utf-8″);%>
相关文档:
pageEncoding:设置JSP源文件和响应正文中的字符集编码。
contentType:设置JSP源文件和响应正文的字符集编码及MIME类型。
可见,pageEncoding和contentType都可以设置JSP源文件和响应正文中的字符集编码。但也有区别:
设置JSP源文件字符集时,优先级为pageEncoding>contentType。如果都没有设置,默认ISO-8859-1。
......
jsp内置对象
定义:可以不加声明就在JSP页面脚本(Java程序片和Java表达式)中使用的成员变量
JSP共有以下9种基本内置组件(可与ASP的6种内部组件相对应):
内置对象
代表内容
范围
request
触发服务调用的请求
request
response
对请求的应答
page
session
为请求的客户创建的sessio ......
I used Eclipse to try the google app engine demo project: guestbook.
when i create a *.jsp file in the WAR directory,the error information appear:
"Your Web Application Project must be configured to use a JDK in order to use JSPs."
solution:
It is because Eclipse put the JRE to the JRE directory ......
当你在客户端用view source看JSP生成的代码时,会发现有很多空行,他们是由< %...% >后的回车换行而生成的,也就是说每一行由< %...% >包含的JSP代码到客户端都变成一个空行,虽然不影响浏览,但还是希望能把他们删掉。这里将为大家介绍如何删除JSP编译后的空行。
Tomcat删除JSP编译后的空行办法如下:
1. ......
1、 在JSP文件上使用标签库
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
时出现问题,错误信息如下:
he absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar fil ......