使用工具开发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相关推荐

  1. Struts学习笔记--(二)Struts基础

    本文为how2java Struts教程的学习笔记,原教程链接如下:http://how2j.cn/k/struts/struts-jsp/55.html 中文问题 修改addProductjsp 修 ...

  2. 台湾国立大学郭彦甫Matlab教程笔记(22) Cramer's method(Inverse matrix逆矩阵法)

    台湾国立大学郭彦甫Matlab教程笔记(22) Cramer's method(Inverse matrix) matrix left division左除:\ or mldivide() solvi ...

  3. 台湾国立大学郭彦甫Matlab教程笔记(21)linear equations(高斯消去法和追赶法)

    台湾国立大学郭彦甫Matlab教程笔记(21) today: linear equation 线性方程 linear system 线性系统 我们先看第一部分 linear equation 假定一个 ...

  4. 台湾国立大学郭彦甫Matlab教程笔记(20) root finding(numeric)

    台湾国立大学郭彦甫Matlab教程笔记(20) root finding(numeric) symbolic vs. numeric符号法和数值法的区别对比 symbolic 1)advantages ...

  5. 台湾国立大学郭彦甫Matlab教程笔记(17)numerical integration

    台湾国立大学郭彦甫Matlab教程笔记(17)numerical integration 数值积分 calculating the numerical value of a definite inte ...

  6. 台湾国立大学郭彦甫Matlab教程笔记(16) 数值微分 numerical differentiation

    台湾国立大学郭彦甫Matlab教程笔记(16) 数值微分 numeric differentiation 复习:diff()函数用来计算vector前后 entry的差异 数值微分继续 various ...

  7. 台湾国立大学郭彦甫Matlab教程笔记(15)polynomial integration 多项式积分

    台湾国立大学郭彦甫Matlab教程笔记(15) Polynomial integration多项式积分 一个多项式和它的积分如下 MATlAB中如何计算积分? polynomial integrati ...

  8. 台湾国立大学郭彦甫Matlab教程笔记(14)polynomial differentiation多项式微分

    台湾国立大学郭彦甫Matlab教程笔记(14) today: polynomial differentiation and integration多项式微分与积分 numerical differen ...

  9. 台湾国立大学郭彦甫Matlab教程笔记(12) advanced 2D plot 下

    台湾国立大学郭彦甫Matlab教程笔记(12) advanced 2D plot 下 上文记录的是关于统计的图标的绘制 下面我们来到另一个模块:颜色 fill()填充函数 功能:某一个封闭曲线,图上特 ...

  10. 台湾国立大学郭彦甫Matlab教程笔记(11) advanced 2D plots 上

    台湾国立大学郭彦甫Matlab教程笔记(11) today: 1.advanced 2D plots 2.color space色彩使用 3.3D plots 图形概览,做研究的时候需要选择图形 sp ...

最新文章

  1. python实现迭代的快速排序(Iterative Quick Sort)
  2. 一步一步教你如何导出JAR包后将多个JAR包合并,并混淆
  3. java对象与c网络语言通信,JAVA与C语言的网络通信代码案例.pdf
  4. Radware:应用交付向云端扩展
  5. 软考高项-信息系统项目管理师-精华笔记
  6. jszip 解压压缩包_使用zip.js压缩文件和解压文件
  7. 算法之BFS算法框架
  8. 【PPT在插入excel对象时报错】
  9. Tomcat之deamon守护线程
  10. 找茬小游戏微信小程序源码自带流量主功能+前端+后端+教程
  11. 基于微信小程序的课程学习小程序
  12. 使用简单的神经网络实现区分鸢尾花类别
  13. 车载网络技术——CAN总线基础
  14. Linux入门参考文档(超详细)
  15. 只需Ctrl+T,让 Excel 变身为「超级表格」
  16. zigbee以太网网关方案
  17. Explaining and Harnessing Adversarial Examples
  18. C++算法篇:DFS超详细解析(2)--- tarjan算法求无向图割边
  19. STM32芯片替代方案 | 从原厂资料中获取GD32F103VET6通信I2C接口电路设计 | 第四集
  20. T2080 U-BOOT与OS内核移植 准备篇(二)——开发调试环境入门(Trace32、QorIQ Linux SDK和QCVS)

热门文章

  1. VC++动态链接库编程之DLL木马(转)
  2. 自定义类加载器与热部署
  3. 阿里P9谈程序员——程序员的青春饭
  4. gh-ost 学习笔记
  5. 【No.11 默认实参的匹配】
  6. 汇编程序:成绩分段统计
  7. scala学习手记15 - 独立对象和伴生对象
  8. 30个灵感来自大自然的国外网页设计作品欣赏
  9. 保持皮肤水嫩有光泽,让皮肤保湿的土办法 - 生活至上,美容至尚!
  10. Wine——在Linux上运行Windows软件