struts2+spring+mybatis入门教程二之配置struts2
来源:互联网 发布:智尚网络 编辑:程序博客网 时间:2024/06/05 23:55
(1)Eclipse新建Dynamic Web Project工程,工程名SSM,在WEB_INF下新建文件夹classes工程默认输出路径设置为classes文件夹,删除eclipse默认生成的build文件夹。如下图:
(2)web目录下新建文件夹demo,demo下新建文件demo.jsp,内容hello demo.jsp。如下图:
(3)将struts相关jar包拷贝到web-inf/lib下,修改web.xml,配置struts核心转发器。web.xml代码:
<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><display-name>SSM</display-name><welcome-file-list><welcome-file>/demo/demo.jsp</welcome-file></welcome-file-list><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></web-app>
(4)在src下新建包com.xy6,在包下新建类DemoAction.java,集成struts的ActionSupport类,并在类中添加execute()方法。DemoAction.java代码:
package com.xy6;import com.opensymphony.xwork2.ActionSupport;public class DemoAction extends ActionSupport {public static final long serialVersionUID = 1L;public String execute(){return "success";}}
(5)在src下新建文件struts.xml,配置package及action。struts.xml代码:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><package name="demo" extends="struts-default"><action name="demo" class="com.xy6.DemoAction" method="execute"><result name="success">/demo/demo.jsp</result></action></package></struts>
(6)启动weblogic,新建域,域名SSM,将端口号改为9001(7001、8001在我电脑上已被其它域占用),新建结束启动域服务,将SSM工程部署到该域中,state为active表示工程已部署成功,可以响应请求。如下图:
(7)在浏览器中访问http://localhost:9001/web/demo.action,页面显示demo.jsp。如下图:
(8)至此,struts配置结束。
0 0
- struts2+spring+mybatis入门教程二之配置struts2
- struts2+spring+mybatis入门教程四之配置mybatis
- struts2+spring+mybatis入门教程三之配置spring2
- struts2+spring+mybatis入门教程五之配置log4j
- struts2+spring+mybatis入门教程六之配置json
- struts2+spring+mybatis入门教程五之配置log4j
- struts2+spring+mybatis入门教程七之常见问题
- struts2+spring+mybatis入门教程一之开发环境
- struts2+spring+mybatis入门二
- struts2+spring+mybatis简单配置
- Struts2+spring+Mybatis 简单配置
- Struts2+Spring+Mybatis 配置讲解
- 整理struts2+spring+mybatis简单配置
- spring整合struts2、mybatis的配置
- 框架整合之Spring + Struts2 + MyBatis
- Spring IBatis Struts2 集成之二:Spring与Struts2集成
- spring + struts2 + mybatis整合
- spring+struts2+mybatis整合
- excel文件的格式设置及文件创建
- OpWeb——MySQL同步模块(2)
- 黑马程序员——学习笔记15.学习反射时张老师提到的两个思考题
- 关于web文档的语言
- java ssh中文乱码问题综合
- struts2+spring+mybatis入门教程二之配置struts2
- JDBC连接Oracle数据库
- android HttpURLConnection类的getInputStream方法返回中文显示乱码问题
- XXX is not in the sudoers file解决方法
- iOS上传视频道优酷视频文件MD5的获取等
- android客户端和服务端js交互
- 黑马程序员_IO流之递归
- (转)IOS自定义UITabBar
- (转)IOS自定义UITabBar