关于struts2中警告消息问题的解决方法

来源:互联网 发布:中走丝编程软件 编辑:程序博客网 时间:2024/06/10 21:22

最近玩用重新用了下ssh,跟以前相比无非是版本上有些不一样,也就stuts2和struts1有些不一样其他的都差不多。

进入正题:

工程正常运行以后,出现很多诸如Could not find property [templateDir]

 

2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [org.apache.catalina.jsp_file]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [struts.valueStack]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [templateDir]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [templateDir]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [theme]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [theme]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [templateDir]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [templateDir]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [theme]
2008-9-1 12:16:01 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [theme]
2008-9-1 12:16:03 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [.freemarker.Request]
2008-9-1 12:16:03 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [.freemarker.RequestParameters]
2008-9-1 12:16:03 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [actionErrors]
2008-9-1 12:16:03 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Could not find property [actionErrors]

 

......

 

 

等警告信息。

 

搜了一下,都问的人不少,解决方案几乎没有,于是乎来到apache官网搜了一把,貌似有提到这个。

参考地址:http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-MissingProperties

 

主要内容如下:

Missing Properties

This message states that the framework searched for a property in the value stack and failed to find it.

2008-04-19 14:21:08,177 WARN  [http-8443-Processor25] [OgnlValueStack] Could not find property [templateDir]2008-04-19 14:21:08,177 WARN  [http-8443-Processor25] [OgnlValueStack] Could not find property [templateDir]2008-04-19 14:21:08,177 WARN  [http-8443-Processor25] [OgnlValueStack] Could not find property [templateDir]2008-04-19 14:21:08,178 WARN  [http-8443-Processor25] [OgnlValueStack] Could not find property [org.apache.catalina.jsp_file]

To hide these messages, turn off the WARN level logging for OgnlValueStack.

eg. Include a new limit category in your log4j.xml file (only log errors or worse):

<category name="com.opensymphony.xwork2.ognl.OgnlValueStack">      <priority value="error"/>   </category>
原来是少了log4j配置文件,顿悟+无语。。。。。
看一下lib包,果然没有log4j-xxx.jar,到apache下个log4j-1.2.9.jar包放到lib下。
现在不需要写log4.xml也不会出现警告信息。
如果加上去也可以,把日志信息的级别调整为ERRORJ即可。
若水用的是log4j.properties文件并没有用log4j.xml(个人习惯而已),考虑到有些朋友对log4j不太熟悉
贴一下代码
log4j.properties 放在src目录下就好了,记得在系统盘上建立log4j.appender.logfile.File对应的文件。
# For JBoss: Avoid to setup log4j outside $JBOSS_HOME/server/default/deploy/log4j.xml
# For all other servers: Comment out the Log4J listener in web.xml too
log4j.rootLogger=ERROR, console, logfile
#console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %p [%c] - <%m>%n
#log4j.appender.console.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
#logfile
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=C:/ask/logs/ask.log
# Log4j Max File Size
# log4j.appender.logfile.MaxFileSize=10MB
# Log4j BackUp File Index
# log4j.appender.logfile.MaxBackupIndex=10
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
# Pattern to output: date priority [category] - <message>line_separator
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n
#log4j.logger.org.hibernate=info   
#log4j.logger.org.hibernate=debug    
   
### log HQL query parser activity  
#log4j.logger.org.hibernate.hql.ast.AST=debug  
   
### log just the SQL  
#log4j.logger.org.hibernate.SQL=info  
   
### log JDBC bind parameters ###  
#log4j.logger.org.hibernate.type=info  
#log4j.logger.org.hibernate.type=debug  
   
### log schema export/update ###  
#log4j.logger.org.hibernate.tool.hbm2ddl=debug  
   
### log HQL parse trees  
#log4j.logger.org.hibernate.hql=info  
   
### log cache activity ###  
#log4j.logger.org.hibernate.cache=debug  
   
### log transaction activity  
#log4j.logger.org.hibernate.transaction=debug  
   
### log JDBC resource acquisition  
#log4j.logger.org.hibernate.jdbc=debug  
   
### enable the following line if you want to track down connection ###  
### leakages when using DriverManagerConnectionProvider ###  
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace  
 
打完收工,继续写代码。。。
正在模仿www.javaeye.com/ask做ssh练手。
原创粉丝点击