关于Struts2中struts.xml文件分层问题

没事折腾struts2,遇到异常,浪费好长时间,于是干脆把所有可能的异常都给跑一遍,来个痛快的。

文件的结构

WEB-INF

|------configs

|-------struts-common.xml

|-------struts.xml

|------web.xml

遇到的异常:

WARNING: Could not find action or result: /Pro_struts2/common/login!preLogin
There is no Action mapped for action name login!preLogin. - [unknown location]
	at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
	at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
	at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
	at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)

一般情况下struts的配置文件都是放在src文件目录下。我想把这些配置文件放到WEB-INF目录下面,然后在web.xml中告诉系统这些文件的位置。xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>Pro_struts2</display-name>

	<!-- 注册struts框架过滤器 -->
	<filter>
		<filter-name>struts</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
		<init-param>
			<description>指定struts.xml文件位置</description>
			<param-name>config</param-name>
			<span style="color:#ff0000;"><param-value>configs/struts.xml</param-value>
</span>		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>struts</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>

参见红色字体部分,错误原因:此处路径是相对于web.xml本身,因此路径应该修改为“../configs/struts.xml”

修改好后,服务器启动报错:

SEVERE: Dispatcher initialization failed
com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:144)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:113)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:90)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)
	at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:71)
	at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:67)
	at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)
	at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:116)
	at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:490)
	at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:530)
	at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:528)
	at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:584)
	at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:528)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:257)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
	at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:670)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)
Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
	at com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:239)
	at com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:229)
	at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:293)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:117)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:114)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:141)
	... 38 more

Jul 02, 2014 3:34:30 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts
com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory). - Class: com.opensymphony.xwork2.inject.ContainerImpl
File: ContainerImpl.java
Method: addInjectorsForMembers
Line: 144 - com/opensymphony/xwork2/inject/ContainerImpl.java:144:-1
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
	at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:670)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)
Caused by: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:144)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:113)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:90)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)
	at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:71)
	at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:67)
	at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)
	at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:116)
	at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:490)
	at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:530)
	at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:528)
	at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:584)
	at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:528)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:257)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
	... 19 more
Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
	at com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:239)
	at com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:229)
	at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:293)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:117)
	at com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:114)
	at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:141)
	... 38 more

错误原因,当struts.xml文件不再src下时,无法自动关联到strtus-default.xml文件,因此需要以下配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>Pro_struts2</display-name>

	<!-- 注册struts框架过滤器 -->
	<filter>
		<filter-name>struts</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
		<init-param>
			<description>指定struts.xml文件位置</description>
			<param-name>config</param-name>
			<param-value><span style="color:#ff0000;">struts-default.xml,</span>../configs/struts.xml</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>struts</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>

这样处理之后,启动就不会报错了。

由于struts文件也被分割成两个文件,struts.xml 使用include标签将sturts-common.xml包含进来。sturts.xml文件内容

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
	<!-- 这些属性可以再struts的StrutsConstant.java中找到 -->
	<constant name="struts.devMode" value="true"></constant>
	<constant name="struts.custom.i18n.resources" value="MessageResource"></constant>
	<constant name="struts.i18n.encoding" value="utf-8"></constant>
	<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>

	<include file="struts-common.xml"></include>
</struts>

服务器启动没有问题,但是无法访问到sturts-common.xml中的Action,报错信息如下

SEVERE: Could not find action or result
/Pro_struts2/common/login!preLogin
There is no Action mapped for action name login. - [unknown location]
	at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
	at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
	at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
	at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)

错误原因:虽然sturts.xml在configs文件夹中,但是编译后struts.xml文件的位置是在WEB-INF/classes下面的,因此相对路径应该相对于classes文件夹。修改如下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
	<!-- 这些属性可以再struts的StrutsConstant.java中找到 -->
	<constant name="struts.devMode" value="true"></constant>
	<constant name="struts.custom.i18n.resources" value="MessageResource"></constant>
	<constant name="struts.i18n.encoding" value="utf-8"></constant>
	<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>

	<include file="<span style="color:#ff0000;">../configs/</span>struts-common.xml"></include>
</struts>

关于Struts2中struts.xml文件分层问题,布布扣,bubuko.com

时间: 2024-12-14 18:06:19

关于Struts2中struts.xml文件分层问题的相关文章

struts2中struts.xml文件用通配符配置

在使用struts2的时候,能简单快速地连接action和jsp页面.主要是神奇的配置文件:struts.xml 在起作用. 示例: 这是目录结构: 来一份可用的struts.xml的代码: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//

struts2中struts.xml配置文件详解

struts.xml的常用配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts

struts2中struts.xml配置文件详解【未整理】

1.    深入Struts2的配置文件 本部分主要介绍struts.xml的常用配置. 1.1.    包配置: Struts2框架中核心组件就是Action.拦截器等,Struts2框架使用包来管理Action和拦截器等.每个包就是多个Action.多个拦截器.多个拦截器引用的集合. 在struts.xml文件中package元素用于定义包配置,每个package元素定义了一个包配置.它的常用属性有: l name:必填属性,用来指定包的名字. l extends:可选属性,用来指定该包继承

struts2——配置struts.xml文件

在struts2框架中struts.xml是应当放到src的根目录,程序编译后会将struts.xml放到WEB-INF/classes目录下. Struts2在web.xml中的一般配置如下: Xml代码   <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFil

struts2的struts.xml文件的提示功能配置

1.先配置dtd文件 步骤: 1.首先打开MyEclipse的窗口,选择"Window"菜单下的"Preferences"选项 2.再打开的"Preferences"对话框中,选择左边的"XML"选项下的"XML Catalog"选项,然后选择右边的"Add"按钮, 3.选择"File System"按钮,找到dtd文件的位置,(可以解压struts-core-2.5

struts2中struts.xml中的action标签的method属性配置为&quot;{1}&quot;的时候是什么意味

用一个例子来说明 当有如下<action>标签 <action name="user_*" class="com.test.CustomerAction" method="{1}"> <result name="success" >/result.jsp</result> <result name="input">/index.jsp</re

Struts2 学习笔记——struts.xml文件之Bean的配置

Struts2的大部分核心组件不是以硬编码的形式写在代码中,而是通过自身的IoC容器来管理的. Struts2以可配置的形式来管理核心组件,所以开发者可以很容易的扩展框架的核心组件.当开发者需要扩展或者替换Struts2的核心组件时,只需要提供自己的组件实现类,并部署在Struts2的IoC容器中即可. 我们打开struts2-core-2.2.1.1.jar中的struts-default.xml文件,可以看到大量的Bean的定义.如下代码片段: <struts> <!—- 两个对象工

【Struts2】☆★之解决struts.xml文件提示问题

[Struts2]☆★之解决struts.xml文件提示问题 首先需要下载struts架包,下载步骤详情请看[web开发]☆★之Struts2系列教程[1]搭建Struts2开发环境. 下载之后我们新建一个struts.xml文件,如下: 在联网的情况下,IDE会根据这个路径将struts-2.3.dtdt文件下载下来放在缓冲中,但是有些项目比如做银行项目时,开发环境是不允许连接互联网的,因此怎么解决这个问题呢?ok,往下看 将下载好的struts文件打开,找到这个文件,如下: 那么接下来呢?打

struts.xml文件中action配置、OGNL的投影映射、OGNL表达式的符号

在struts.xml文件中不同的action配置,请求的路径是不一样的 1.请求 path = user!query.action; 配置如下: <action name="user" class="com.bwf.code.action.UserAction"> <result name="queryUser">/query.jsp</result> </action> 2.请求path = u