环境: myeclipse6.0+tomcat6.0+struts2.0
新建工程struts2.0
将commons-logging-1.0.4.jar,freemarker-2.3.8.jar,ognl-2.6.11.jar,struts2-core-2.0.14.jar,xwork-2.0.7.jar分别加到classpath和应用的lib下
修改web.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">
<filter>
<filter-name>struts2.0</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2.0</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
在src下建立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>
</struts>
直接部署到tomcat6中可以正确访问到struts2.0应用,但是在模拟tomcat5在cof中建立文件夹conf/Catalina/localhost时,并建立struts2.0.xml映射工作路径
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="struts2.0" docBase="E:/mye6.0_workbench/struts2.0/WebRoot" path="/struts2.0" privileged="true" reloadable="true" workDir="work/Catalina/localhost/struts2.0">
<!--<Resource name="DADJPTDataSource"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@192.168.100.191:1521:oracle"
username="DADJPT"
password="DADJPT"
maxActive="50"
maxIdle="10"
maxWait="5000" />
-->
</Context>
却发生了异常
2009-3-24 20:52:58 org.apache.struts2.config.Settings getLocale
警告: Settings: Could not parse struts.locale setting, substituting default VM locale
解决方案:
在src文件夹下建立struts.properties,并加入下面内容即可
struts.locale=en_GB