`

Struts2 基础

 
阅读更多

由于一些遗忘,去深入了解struts2-convention-plugin-2.2.1.1.jar
觉得这段总结还不错,拿来和大家一起分享下。

 

1.启动Tomcat出现:

Settings: Could not parse struts.locale setting, substituting default VM locale

解决方法->使用是UTF-8在struts.properties文件中配置:struts.locale=en_UTF-8 或 struts.locale=zh_UTF-8

2.启动时LogFactory.java报错的话,就说明struts2的jar包版本有问题看是2.0.*还是2.1.*版本的,重新下载相应的包.

3.There is no Action mapped for namespace / and action name HelloWorld

解决方法:struts.xml写错

4.Unable to locate configuration files of the name struts-plugin.xml, skipping

解决方法:将struts2-convention-plugin-2.2.1.1.jar放进lib即可

5.完整运行一个struts2需要的环境和jar包:

①jar包(9个):

commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.16.jar
javassist-3.7.ga.jar
ognl-3.0.jar
struts2-convention-plugin-2.2.1.1.jar
struts2-core-2.2.1.1.jar
xwork-core-2.2.1.1.jar

②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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>xypm</display-name>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
</web-app>

③Tomcat配置:Server Options->勾选Publish module contexts separate XML files

④下载tcnative-1.dll到jdk/bin下

6.struts2跳转后页面乱码

解决方法:<result type="freemarker">/index.htm</result>记得加type为freemarker

7.http://blog.163.com/huang_ying_lu/blog/static/2699983201111975921355/

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics