struts开发流程及详细
来源:互联网 发布:unity3d开始界面添加 编辑:程序博客网 时间:2024/05/28 17:07
一:Struts开发步骤:
1. web项目,引入struts - jar包2. web.xml中,引入struts的核心功能
配置过滤器
3. 开发action
4. 配置action
src/struts.xml
二:详细配置
1.引入8个jar文件
commons-fileupload-1.2.2.jar 【文件上传相关包】
commons-io-2.0.1.jar
struts2-core-2.3.4.1.jar 【struts2核心功能包】
xwork-core-2.3.4.1.jar 【Xwork核心包】
ognl-3.0.5.jar 【Ognl表达式功能支持表】
commons-lang3-3.1.jar 【struts对java.lang包的扩展】
freemarker-2.3.19.jar 【struts的标签模板库jar文件】
javassist-3.11.0.GA.jar 【struts对字节码的处理相关jar】
2.web.xml详细配置
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 其他拦截器 --> <!-- 引入struts核心过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
3.开发Action(3种方式)
1种:直接继承ActionSupport
package cn.itcast.a_config;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport {// Action中业务处理方法public String login() {System.out.println("UserAction.login()");return "success";}}
2种:继承Action接口
package cn.itcast.a_config;import com.opensymphony.xwork2.Action;import com.opensymphony.xwork2.ActionSupport;public class UserAction implements Action {// Action中业务处理方法public String login() {System.out.println("UserAction.login()");return "success";}@Overridepublic String execute() throws Exception {return null;}}
3种:不继承任何类,不实现任何接口
package cn.itcast.a_config;import com.opensymphony.xwork2.Action;import com.opensymphony.xwork2.ActionSupport;public class UserAction {private String userName;public void setUserName(String userName) {this.userName = userName;}// Action中业务处理方法public String login() {System.out.println("UserAction.login()" + userName);return "login";}public String register() {System.out.println("register()" + userName);return "register";}}
4. 配置action : src/struts.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"><struts> <package name="config" namespace="/" extends="struts-default"> <action name="login" class="cn.a_config.UserAction" method="login"> <result name="success">/index.jsp</result> </action> </package></struts>
1 0
- struts开发流程及详细
- Struts 2详细工作流程及原理
- Struts的运行原理及开发流程
- Struts的详细流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- 详细剖析Struts工作流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- Struts 2详细工作流程
- Struts开发工作流程
- Struts开发工作流程
- Struts开发流程
- struts开发流程
- 汇编语言课程主页
- python中除号/和//的区别
- js正则表达式验证密码格式的几种情况总结
- Mac OS X启动项详解
- linux电脑插入U盘自动挂载而不自动打开
- struts开发流程及详细
- 第八章 Spring Aware扩展
- windows搭建gcc开发环境(msys2)
- 计算Label高度swift
- _snprintf_s, _snprintf_s_l, _snwprintf_s, _snwprintf_s_l
- VS2015 快捷键
- mxnet im2re.py
- mybatis xml中的小于的写法,like模糊查询的写法
- 小白日记——下载进度的顶部通知