搭建JavaWeb+SSH+Tomcat+Eclipse遇到的问题及解决方案

一、在eclipse中3.5中配置struts2出现的错误:

严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

处理方法:

1、核对lib包

commons-fileupload-1.2.1.jar,

commons-io-1.3.2.jar

commons-logging-1.0.4.jar

freemarker-2.3.16.jar

ognl-3.0.jar

struts2-core-2.2.1.jar

xwork-core-2.2.1.jar)

注意2.1以前是没有commons-fileupload-1.2.1.jar,

2、如果struts2版本是2.1以前

web.xml配置过滤器的时候应该是这样:

<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> 

</web-app> 


如果struts2 版本是2.1以上

web.xml配置

<filter>   

<filter-name>struts2</filter-name>   

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter   

</filter-class>   

</filter>   

<filter-mapping>   

<filter-name>struts2</filter-name>   

<url-pattern>/*</url-pattern>   

</filter-mapping>   

</web-app> 

3、在使用struts-2.2.1时,需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。

二、在eclipse中3.5中配置spring2.5出现的错误:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [applicationContext.xml] is invalid;

nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.

原来的spring配置文件头是:


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

改成:


<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

问题解决。

三、在eclipse中3.5中配置hibernate3的配置细节:

1、避免出现log4j的警告信息

在classes文件夹下建立log4j.properties,内容如下:

# Configure logging for testing: optionally with log file

log4j.rootLogger=WARN, stdout

# log4j.rootLogger=WARN, stdout, logfile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

log4j.appender.logfile=org.apache.log4j.FileAppender

log4j.appender.logfile.File=target/spring.log

log4j.appender.logfile.layout=org.apache.log4j.PatternLayout

log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n


2、如果已设计数据库表中的主键,则不用在映射文件中在对应属性中加入

<generator class="native" /></generator>

四、在eclipse中3.5中配置tomcat6遇到的问题

1、在eclipse中启动tomcat时出现Setting property 'source' to 'org.eclipse.jst.jee.server:你的站点名'   did not find a matching property错误

警告的原因是Tomcat6.0的server.xml的context节点中不支持source属性.

解决办法:

1)、在server控制台内,在服务器上点右键--属性

2)、general选项卡中点switch location

这时,location变为:/servers/tomcat6.0 server at localhost.server

3)、在project explore中找到tomcat项目--Tomcat v6.0 Server at localhost.server  这个文件 ,双击打开

4)、在最下面的server option里选中publis module context to separate xml file.保存。(保存时要先停止服务器)


2、Tomcat启动的时候出现下面这样的提示:

2008-3-15 14:24:12 org.apache.catalina.core.AprLifecycleListener init

信息: The APR based Apache Tomcat Native library which allows optimal performanc

e in production environments was not found on the java.library.path: D:\Java\jdk1.5.0_05\bin;.;C:\WINDOWS\system32;C:\WINDOWS;d:\ruby\bin;.;..;D:\Java\jrockit-R26.0.0-jdk

.......

实际这是建议使用apache的apr。

如果想使用apr的话, 实际操作很简单,

下载 http://tomcat.heanet.ie/native/1.1.12/binaries/win32/tcnative-1.dll

将这个文件复制到C:\WINDOWS\system32\,.也可以放在Tomcat安装路径下的bin目录里

然后重新启动tomcat,就会发现tomcat 的控制台信息为:

2008-3-15 14:33:49 org.apache.catalina.core.AprLifecycleListener init

信息: Loaded APR based Apache Tomcat Native library 1.1.12.

2008-3-15 14:33:49 org.apache.catalina.core.AprLifecycleListener init

信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], ra

ndom [true]. 

五、JavaWeb项目中资源文件的基本配置方法,请参见:http://blog.csdn.net/pp1pp1pp2/article/details/3413886
      struts2基本拦截器配置,请参见:http://blog.csdn.net/wangle4717/article/details/5986674
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值