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″);%>
相关文档:
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 ......
package com.gc.tool;
import java.util.ArrayList;
import java.util.List;
public class MyPagination {
private int recordCount = 0;
private int pagesize = 0;
private int maxPage = 0;
&n ......
当你在客户端用view source看JSP生成的代码时,会发现有很多空行,他们是由< %...% >后的回车换行而生成的,也就是说每一行由< %...% >包含的JSP代码到客户端都变成一个空行,虽然不影响浏览,但还是希望能把他们删掉。这里将为大家介绍如何删除JSP编译后的空行。
Tomcat删除JSP编译后的空行办法如下:
1. ......
jsp:useBean标签用于指定在当前Jsp页面中要用到的JavaBean
格式:<jsp:Bean id=? scope=? class=? />
id:自定义一个在当前页面中要引用的JavaBean(即Java类)的一个对象名(该对象在后面的代码中就可以调用其所属的JavaBean中的属性和方法)
scope:用于指定该JavaBean的作用范围,取值如下
&nbs ......