struts教程笔记2
使用工具开发struts,用工具导入struts开发包,手动配置
struts-config.xml
1.建立web工程
2.导入struts开发包
3.开发login.jsp
4.开发action和actionForm
5.开发ok.jsp和err.jsp
6.测试
半自动可以提高开发效率
完全依赖myEclipse工具开发struts
1.建立web工程
2.引入struts capabilities
3.创建login.jsp
4.用struts-config.xml design界面创建userForm表单
5.创建action
6.ok.jsp err.jsp
7.在action中添加业务逻辑
使用工具开发struts,用工具导入struts开发包,手动配置
struts-config.xml
1.建立web工程
2.导入struts开发包
3.开发login.jsp
4.开发action和actionForm
5.开发ok.jsp和err.jsp
6.测试
半自动可以提高开发效率
完全依赖myEclipse工具开发struts
1.建立web工程
2.引入struts capabilities
3.创建login.jsp
4.用struts-config.xml design界面创建userForm表单
5.创建action
6.ok.jsp err.jsp
7.在action中添加业务逻辑
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><servlet><servlet-name>action</servlet-name><servlet-class>org.apache.struts.action.ActionServlet</servlet-class><init-param><param-name>config</param-name><param-value>/WEB-INF/struts-config.xml</param-value></init-param><init-param><param-name>debug</param-name><param-value>3</param-value></init-param><init-param><param-name>detail</param-name><param-value>3</param-value></init-param><load-on-startup>0</load-on-startup></servlet><servlet-mapping><servlet-name>action</servlet-name><url-pattern>*.do</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config><data-sources /><form-beans ><form-bean name="userForm" type="com.xinghua.struts.form.UserForm" /></form-beans><global-exceptions /><global-forwards /><action-mappings ><actionattribute="userForm"input="/WEB-INF/login.jsp"name="userForm"path="/login"scope="request"type="com.xinghua.struts.action.LoginAction"validate="false" ><forward name="err" path="/WEB-INF/err.jsp" /><forward name="ok" path="/WEB-INF/ok.jsp" /></action></action-mappings><message-resources parameter="com.xinghua.struts.ApplicationResources" />
</struts-config>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
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 'index.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"><!--<link rel="stylesheet" type="text/css" href="styles.css">--></head><body><jsp:forward page="/WEB-INF/login.jsp"></jsp:forward></body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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 'login.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"><!--<link rel="stylesheet" type="text/css" href="styles.css">--></head><body><form action="/strutsTools2/login.do" method="post">username:<input type="text" name="username"><br/>password:<input type="password" name="password"><br/><input type="submit" value="login"></form></body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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 'err.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"><!--<link rel="stylesheet" type="text/css" href="styles.css">--></head><body>err <br></body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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 'ok.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"><!--<link rel="stylesheet" type="text/css" href="styles.css">--></head><body>ok<br></body>
</html>
/** Generated by MyEclipse Struts* Template path: templates/java/JavaClass.vtl*/
package com.xinghua.struts.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.xinghua.struts.form.UserForm;/** * MyEclipse Struts* Creation date: 02-20-2020* * XDoclet definition:* @struts.action path="/login" name="userForm" scope="request"*/
public class LoginAction extends Action {/** Generated Methods*//** * Method execute* @param mapping* @param form* @param request* @param response* @return ActionForward*/public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {UserForm userForm = (UserForm) form;// TODO Auto-generated method stubif("123".equals(userForm.getPassword())){return mapping.findForward("ok");}else return mapping.findForward("err");}
}
/** Generated by MyEclipse Struts* Template path: templates/java/JavaClass.vtl*/
package com.xinghua.struts.form;import org.apache.struts.action.ActionForm;/** * MyEclipse Struts* Creation date: 02-20-2020* * XDoclet definition:* @struts.form name="userForm"*/
public class UserForm extends ActionForm {/** Generated fields*//** password property */private String password;/** username property */private String username;/** Generated Methods*//** * Returns the password.* @return String*/public String getPassword() {return password;}/** * Set the password.* @param password The password to set*/public void setPassword(String password) {this.password = password;}/** * Returns the username.* @return String*/public String getUsername() {return username;}/** * Set the username.* @param username The username to set*/public void setUsername(String username) {this.username = username;}
}
struts教程笔记2相关推荐
- Struts学习笔记--(二)Struts基础
本文为how2java Struts教程的学习笔记,原教程链接如下:http://how2j.cn/k/struts/struts-jsp/55.html 中文问题 修改addProductjsp 修 ...
- 台湾国立大学郭彦甫Matlab教程笔记(22) Cramer's method(Inverse matrix逆矩阵法)
台湾国立大学郭彦甫Matlab教程笔记(22) Cramer's method(Inverse matrix) matrix left division左除:\ or mldivide() solvi ...
- 台湾国立大学郭彦甫Matlab教程笔记(21)linear equations(高斯消去法和追赶法)
台湾国立大学郭彦甫Matlab教程笔记(21) today: linear equation 线性方程 linear system 线性系统 我们先看第一部分 linear equation 假定一个 ...
- 台湾国立大学郭彦甫Matlab教程笔记(20) root finding(numeric)
台湾国立大学郭彦甫Matlab教程笔记(20) root finding(numeric) symbolic vs. numeric符号法和数值法的区别对比 symbolic 1)advantages ...
- 台湾国立大学郭彦甫Matlab教程笔记(17)numerical integration
台湾国立大学郭彦甫Matlab教程笔记(17)numerical integration 数值积分 calculating the numerical value of a definite inte ...
- 台湾国立大学郭彦甫Matlab教程笔记(16) 数值微分 numerical differentiation
台湾国立大学郭彦甫Matlab教程笔记(16) 数值微分 numeric differentiation 复习:diff()函数用来计算vector前后 entry的差异 数值微分继续 various ...
- 台湾国立大学郭彦甫Matlab教程笔记(15)polynomial integration 多项式积分
台湾国立大学郭彦甫Matlab教程笔记(15) Polynomial integration多项式积分 一个多项式和它的积分如下 MATlAB中如何计算积分? polynomial integrati ...
- 台湾国立大学郭彦甫Matlab教程笔记(14)polynomial differentiation多项式微分
台湾国立大学郭彦甫Matlab教程笔记(14) today: polynomial differentiation and integration多项式微分与积分 numerical differen ...
- 台湾国立大学郭彦甫Matlab教程笔记(12) advanced 2D plot 下
台湾国立大学郭彦甫Matlab教程笔记(12) advanced 2D plot 下 上文记录的是关于统计的图标的绘制 下面我们来到另一个模块:颜色 fill()填充函数 功能:某一个封闭曲线,图上特 ...
- 台湾国立大学郭彦甫Matlab教程笔记(11) advanced 2D plots 上
台湾国立大学郭彦甫Matlab教程笔记(11) today: 1.advanced 2D plots 2.color space色彩使用 3.3D plots 图形概览,做研究的时候需要选择图形 sp ...
最新文章
- python实现迭代的快速排序(Iterative Quick Sort)
- 一步一步教你如何导出JAR包后将多个JAR包合并,并混淆
- java对象与c网络语言通信,JAVA与C语言的网络通信代码案例.pdf
- Radware:应用交付向云端扩展
- 软考高项-信息系统项目管理师-精华笔记
- jszip 解压压缩包_使用zip.js压缩文件和解压文件
- 算法之BFS算法框架
- 【PPT在插入excel对象时报错】
- Tomcat之deamon守护线程
- 找茬小游戏微信小程序源码自带流量主功能+前端+后端+教程
- 基于微信小程序的课程学习小程序
- 使用简单的神经网络实现区分鸢尾花类别
- 车载网络技术——CAN总线基础
- Linux入门参考文档(超详细)
- 只需Ctrl+T,让 Excel 变身为「超级表格」
- zigbee以太网网关方案
- Explaining and Harnessing Adversarial Examples
- C++算法篇:DFS超详细解析(2)--- tarjan算法求无向图割边
- STM32芯片替代方案 | 从原厂资料中获取GD32F103VET6通信I2C接口电路设计 | 第四集
- T2080 U-BOOT与OS内核移植 准备篇(二)——开发调试环境入门(Trace32、QorIQ Linux SDK和QCVS)