JAVA-STRUTS-2x的项目配置
首先是web.xml的配置,这个是项目加载的开始。
<display-name></display-name>
<!--struts2配置开始-->
<filter>
<filter-name>struts2</filter-name><!--和mapping中name一致-->
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<!--struts2配置结束-->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
然后是src下的struts.xml文件,它是struts配置文件的源头。
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts>
<!-- 编码 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<!-- 扩展名 -->
<constant name="struts.action.extension" value="do,action" />
<!-- 浏览器是否缓存静态数据 -->
<constant name="struts.serve.static.browserCache" value="false" />
<!-- struts配置文件修改后自动加载 -->
<constant name="struts.configuration.xml.reload" value="true" />
<!-- 开发模式下打印出更详细的错误信息 true false -->
<constant name="struts.devMode" value="true" />
<!-- 默认主体 -->
<constant name="struts.ui.theme" value="simple" />
<!-- 是否支持动态调用 -->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<!-- 上传文件的大小 -->
<constant name="struts.multipart.maxSize" value="2097152" /> <package name="base" extends="struts-default"></package>
<include file="strutsxml/struts.xml"></include> <!-- 值是可以变的,改成你对应的文件就好 -->
<include file="strutsxml/struts_ajax.xml"></include> <!-- 可以加载多个子配置文件 -->
</struts>
加载主配置文件后,会加载子配置文件。这里就写出一个了,另一个可有可无,看项目结构了。
strutsxml/struts.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts>
<package name="default" extends="base" namespace="/">
<!-- class的值对应java类,默认调用execute方法;可增加属性method,值为方法名已修改调用方法 -->
<action name="Categories" class="com.junjuping.ui.action.Categories">
<result name="succ">/CategoriesList.jsp</result> <!-- 对应jsp文件;name值则为java类返回的字符串 -->
</action>
</package>
</struts>
子配置文件的action标签也可直接放到主配置文件中(package标签里)。
默认调用对应的java类中的execute方法。
com.junjuping.ui.action.Categories.java
public class Categories
{
public String execute() throws Exception {
String result = ""; // 返回值
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
CategoriesServce categoriesServce = new CategoriesServce();
ArrayList<String[]> resultList = categoriesServce.select();
request.setAttribute("resultList", resultList);
result = "succ";
return result;
}}
jsp文件在这里就不再说明了。
JAVA-STRUTS-2x的项目配置的更多相关文章
- 天坑 之 java web servlet+jsp项目 配置后 404 (MyEclipse转eclipse)
最近搞一个自己的博客系统玩,用了servlet+jsp,结果发现了两个大问题: 1.无法 Export 出 WAR文件: 2.生成WAR,放置到TOMCAT的 webapps目录后,http://lo ...
- [转]Java Web笔记:搭建环境和项目配置(MyEclipse 2014 + Maven + Tomcat)
来源:http://www.jianshu.com/p/56caa738506a 0. 绪言 Java Web开发中,除了基础知识外,开发环境搭建,也是一项基本功.开发环境包括了IDE.项目管理.项目 ...
- SpringBoot(十):读取application.yml下配置参数信息,java -jar启动时项目修改参数
读取application.yml下配置参数信息 在application.yml文件内容 my: remote-address: 192.168.1.1 yarn: weburl: http://1 ...
- Atitit.java c#.net php项目中的view复用(jsp,aspx,php的复用)
Atitit.java c#.net php项目中的view复用(jsp,aspx,php的复用) 1.1. Keyword1 1.2. 前言1 2. Java项目使用.Net的aspx页面view1 ...
- struts.xml在Action配置具体解释
在博客上我已经基本上解释struts.xml基本配置.配置过程最为基本的是action的动态配置. 一.Action的创建方法 1)实现Action接口 2)继承ActionSupport类,覆写当中 ...
- Spring+mybatis+struts框架整合的配置具体解释
学了非常久的spring+mybatis+struts.一直都是单个的用他们,或者是两两组合用过,今天总算整合到一起了,配置起来有点麻烦.可是配置完一次之后.就轻松多了,那么框架整合配置具体解释例如以 ...
- 从零开始学 Java - Spring 集成 Memcached 缓存配置(二)
Memcached 客户端选择 上一篇文章 从零开始学 Java - Spring 集成 Memcached 缓存配置(一)中我们讲到这篇要谈客户端的选择,在 Java 中一般常用的有三个: Memc ...
- maven 项目配置
创建java web的maven项目方法有两种,一是先创建maven项目,再选择jdk 和 dynamic web 运行环境 ,二是创建java项目,然后转化为maven项目 1.将普通java项目转 ...
- VC项目配置基础以及快捷键(收藏)
来自http://blog.csdn.net/phunxm/article/details/5082488 一.IDE基础配置 1.字体 VC6中“Tools→Options→Format→Font” ...
- 理解 IntelliJ IDEA 的项目配置和Web部署
1.项目配置的理解 IDEA 中最重要的各种设置项,就是这个 Project Structre 了,关乎你的项目运行,缺胳膊少腿都不行.最近公司正好也是用之前自己比较熟悉的IDEA而不是Eclipse ...
随机推荐
- python基础教程总结15——1.即时标记
1. 测试文档: # test_input.txt Welcome to World Wide Spam. Inc. These are the corporate web pages of *Wor ...
- MovieReview—Black Panther(黑豹)
Justice & Evil The night before the night, i saw the latest movie in the Marvel series at JiaH ...
- FreeRTOS笔记
任务的创建和删除(静态方法) 任务创建后要开启调度器. FreeRTOSConfig.h 1. 改宏 使能静态创建函数. 会出现,有两个函数未定义. Cortex-M中断管理(上) NVIC:嵌套向量 ...
- Array - Remove Element
/** * 无额外空间.顺序可以被改变.不需要修改后面的数字. * @param nums 数组 * @param val 目标值 * @return nums中移除val后的长度 */ public ...
- xml文件读取
xml文件如下: <annotation> <folder>bnrc</folder> <filename>jena_000000_000019_lef ...
- 重新postgresql出现错误:Problem running post-install step. Installation may not complete correctly. The database cluster initialisation failed.
以前正常使用的postgresql,今天出现问题:报*.dll错误.百度了一下,只能重新安装 . 在重新安装过程中报:Problem running post-install step. Instal ...
- 学习笔记(五): Feature Crosses
目录 Feature Crosses Encoding Nonlinearity Kinds of feature crosses Glossay Crossing One-Hot Vectors P ...
- 我的offer之路(一)
目录 1.职业规划. 2.刷题. 3.看书. <剑指offer> <数据结构算法与应用:C++语言描述 > <Effective C++> <C与指针> ...
- MATLAB编程技巧
[摘要] MATLAB是一种科学计算语言,和C.Fortran等高级语言相类似,能方便的实现程序控制.以下介绍一点matlab编程的技巧. 嵌套计算 程序执行的速度取决于调用的子程序的个数和算法实现. ...
- PostgreSQL学习(1)-- 安装pageinspect extension
1.源码编译 pageinspect的源码在postgre源码包的contrib目录下,解压postgre源码包后进入对应的目录. [root@localhost pageinspect]# pwd ...