struts的Html标签与Jsp的区别

来源:百度知道 编辑:UC知道 时间:2024/05/07 13:54:21
<%@ page language="java" import="java.util.*"

pageEncoding="UTF-8"%>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags

-html"%>
<html>
<head>
</head>
<body>
<html:form action="loginaction.do">
用户名:<html:text property="username"/><br>
密码:<html:password property="password"/><br>
<html:submit value="登陆"/>
</html:form>
<html:errors/>
</body>
</html>
=============================================
<%@ page language="java" import="java.util.*"

pageEncoding="UTF-8"%>
<html>
<head>
</head>
<body>
&l

因为struts的<html:form>标签的默认提交方式为post
而<form>的默认提交方式是get
你可能使用过滤器处理过post方式提交的乱码,而没有处理过get的

这样写:

<%@ 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">
。。。

JSP不识别中文,1楼那样不一定行的,数据库里应该还是乱码

最好的办法是在JSP页面加段代码处理:
<%
String str=request.getParameter("username");
byte b[]=str.getByte("ISO-8859-1") ;
str=new String(b);
%>

页头也要改,跟一楼一样就行了

页头改成:
<%@ page language="java" contentType="text/html; charset=gb2312"
pa