EL表达式读表单参数

来源:互联网 发布:mac修图软件哪个好用啊 编辑:程序博客网 时间:2024/05/29 08:35

用struts2可以避免中文乱码

<%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8"%><%@ taglib prefix="s" uri="/struts-tags"%><!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"><title>EL表达式</title></head><body><s:form action="index.jsp"><s:textfield key="username" /><s:submit /></s:form><p>Hello ${param['username']}</p></body></html>
下面这种写法中文会有乱码

<%@ 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"><title>EL读表单传过来的参数</title></head><body><table border="1"><tr><td colspan="2">Hello ${param['name']}</td></tr><tr><form action="NewFile.jsp" method="post"><td><input type="text" name="name"></td><td><input type="submit"></td></form></tr></table></body></html>

源代码:http://pan.baidu.com/share/link?shareid=771957034&uk=3878681452

原创粉丝点击