eclipse学习(第二章:初识ssh)——23.struts整合Tiles

前言

本文是参考自https://www.w3cschool.cn/struts_2/struts_tiles.html做的一个实践日志记录。

jar包下载地址

相关jar包请到该网站下载,下载一个all版本吧
https://struts.apache.org/download.cgi

初始化项目以及jar包拉取

这里需要的将上面网站下载下来的解压后找到lib文件夹,将跟tile有关的jar包拉进去,然后有个联系包struts2-tiles-plugin-2.3.37,然后导入一些struts的包即可。
在这里插入图片描述

创建MenuAction

MenuAction ,这里主要是创建两个方法作为action调用

package com.czx.tiles.action;

import com.opensymphony.xwork2.ActionSupport;

public class MenuAction extends ActionSupport {
	
	public String tiger() {
		return "tiger";
	}

	public String lion() {
		return "lion";
	}
	
	public String baseLayout() {
		return "baseLayout";
	}
}

找图片

百度找三张,分别是老虎,狮子,转换的图片,然后存放到新建的images文件夹下

修改web.xml

这里主要是做一个配置文件位置指定以及监听器的处理

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>ssh_learn_tiles_integration</display-name>
  <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>
  
  <context-param>
   <param-name>
      org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
   </param-name>
   <param-value>
      /WEB-INF/tiles.xml
   </param-value>
   </context-param>
  
  <listener>
   <listener-class>
      org.apache.struts2.tiles.StrutsTilesListener
   </listener-class>
   </listener>

   <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>
  		org.apache.st
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值