Struts2表单标签初步使用可以对表单进行回显
2016-11-17 13:43
393 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'testTag.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<s:form action="myform.action" method="post">
<s:textfield name="username" label="用户名"></s:textfield>
<s:password name="password" label="密码"></s:password>
<s:textarea name="desc" label="文本域"></s:textarea>
<s:submit></s:submit>
</s:form>
</body>
</html>
2;Action
package com.study;
public class UserAction {
private String userId;
private String username;
private String password;
private String desc;
public UserAction() {
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String save()
{
System.out.println(this);
return "input";
}
}
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'testTag.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<s:form action="myform.action" method="post">
<s:textfield name="username" label="用户名"></s:textfield>
<s:password name="password" label="密码"></s:password>
<s:textarea name="desc" label="文本域"></s:textarea>
<s:submit></s:submit>
</s:form>
</body>
</html>
2;Action
package com.study;
public class UserAction {
private String userId;
private String username;
private String password;
private String desc;
public UserAction() {
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String save()
{
System.out.println(this);
return "input";
}
}
相关文章推荐
- Struts2 中使用token标签防止刷新和后退进行重复提交
- struts2 lesson six struts2中的拦截器,过滤器,自定义拦截器,使用拦截器解决表单重复提交,常用标签的使用
- struts2中部分标签使用(for 4000 m表单)
- struts2官方 中文教程 系列十一:使用XML进行表单验证
- struts2使用标签进行循环
- Struts2 常用的表单标签使用
- struts2中非表单标签的使用 componen
- struts2 标签里面不能使用el表达式可以使用ongl表达式
- 基于Struts2框架实现登录案例 之 使用Struts2标签库简化表单+继承ActionSupport完成输入交验
- struts2-21使用标签防止表单重复提交
- struts2 标签里面不能使用el表达式可以使用ongl表达式
- Struts2 中使用token标签防止刷新和后退进行重复提交
- Struts2的表单标签使用
- 防止表单重复提交(拦截器)一些struts2标签的使用
- 使用struts2的标签s:if获取url中的参数值,并与字符串常量进行比较
- struts2标签使用中,什么时候用#,什么时候可以不用#
- 使用image元素也可以进行表单的提交
- Struts2获取HTML表单元素与Struts表单标签的区别使用-基础篇
- Struts2的表单标签还可以为集合中的对象赋值
- 使用input type=file标签进行文件上传时,在安卓手机中的微信浏览器中不能调起相机,但是在苹果手机中的微信浏览器中可以调用相机。解决办法很简单, <input type="file" nam