您的位置:首页 > 编程语言 > Java开发

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";

 }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: