struts2框架配置
来源:互联网 发布:网络平台服务协议 编辑:程序博客网 时间:2024/06/05 11:24
struts2框架配置
- 项目整体结构
- web.xml
过滤器是必要的,其他的辅助配置暂时不管
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>HelloWord</display-name> <!-- 过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.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>
- struts.xml
1. :将每个功能模块独立出来 用include引用
2.
3. 拦截器
4. 全局配置 类似于ssm中的jdbc.properties)
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"><struts> <package name="default" namespace="/" extends="struts-default"> <action name="as" class="com.wx.Action.HelloWorldAction"> <result>/result.jsp</result> </action> <action name="result"> <result>/result.jsp</result> </action> </package></struts>
- HelloWorldAction.java
package com.wx.Action;import com.opensymphony.xwork2.ActionSupport;public class HelloWorldAction extends ActionSupport { /** * */ private static final long serialVersionUID = -8615452363248473209L; @Override public String execute() throws Exception { System.out.println("Action:第一个struts项目"); return SUCCESS; }
- result.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Insert title here</title></head><body> This is my first Struts2:result.jsp</body></html>
- index.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body><a href="as.action">请求struts</a><a href="result.action">请求struts</a></body></html>
阅读全文
0 0
- struts2框架和配置
- Struts2框架(二)配置
- Struts2初次框架配置
- JavaWeb(框架----Struts2):-----配置
- 框架配置----Struts2
- struts2框架配置
- Struts2框架4.Struts2配置详解
- Struts2框架6.Result配置
- Struts2框架开发环境配置
- Struts2框架开发环境配置
- 初学搭建struts2框架的配置步骤
- Struts2框架——环境配置
- 搭建SSH框架之配置Struts2
- 使用struts2框架,web.xml怎么配置
- SSH:Struts2框架(Action的配置)
- Struts2框架9.拦截器配置
- Struts2框架的XML配置详解
- 1. Struts2框架之配置详解
- CSS
- 第7周项目5 排队看病模拟
- 用两个栈来实现一个队列
- linux之在当前目录下删除不包含aa的文件
- Spring MVC的web.xml配置加解析
- struts2框架配置
- Thread类源码分析
- [agc009d]Uninity
- 单例的7种写法
- 【单链表经典面试题解析四】用单链表实现约瑟夫环
- CentOS7设置中文
- 条款19:设计class犹如设计type
- 编程之旅之前端学习初体验
- CentOS xueliang is not in the sudoers file. This incident will be reported