首页 技术 正文
技术 2022年11月8日
0 收藏 548 点赞 1,393 浏览 2226 个字

1.导入struts的基本jar包

ssh整合之四单独搭建struts的运行环境

2.在web.xml中配置我们struts的核心控制器StrutsPrepareAndExecuteFilter

  

<?xml version="1.0" encoding="UTF-8"?>
  <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>ssh_spring</display-name>
    <filter>
      <filter-name>ssh</filter-name>
      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>ssh</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
  </web-app>

3.编写我们的CustomerAction

 

package com.itheima.action;import com.itheima.entity.Customer;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;public class CustomerAction extends ActionSupport implements ModelDriven<Customer> {
private Customer customer = new Customer(); public Customer getModel() {
return customer;
} //进入添加页面
public String addCustomerUI(){
return this.SUCCESS;
}
//进入列表页面
public String getAllCustomer(){
return this.SUCCESS;
}
}

4.编写我们的struts的核心配置文件struts.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
  <package name="customer" extends="struts-default" namespace="/customer">
  <!--
  1.class: 全限定类名
  反射的请示创建动作类对象
  class:需要修改为容器中动作类的bean的唯一标识
  -->
    <action name="addCustomerUI" class="com.itheima.action.CustomerAction" method="addCustomerUI">
      <result name="success">/jsp/customer/add.jsp</result>
    </action>
    <action name="getAllCustomer" class="com.itheima.action.CustomerAction" method="getAllCustomer">
      <result name="success">/jsp/customer/list.jsp</result>
    </action>
  </package>
</struts>

5.导入我们的jsp页面,并对我们的jsp页面中内容进行修改

ssh整合之四单独搭建struts的运行环境

完了我们把我们的项目部署到tomcat上,然后访问地址  http://localhost:8080/ssh_spring/

ssh整合之四单独搭建struts的运行环境

这样的话,我们的struts的单独运行环境就搭建好了,每天进步一点点!

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848