免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2975 | 回复: 1
打印 上一主题 下一主题

Java SSH 中注入屬性問題 求教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-07-14 16:12 |只看该作者 |倒序浏览
目前為公司做一個項目碰到如下問題即使用spring注入時初始化值正確在setter中觀察,但在struts中調用時值又為null了。
為了進一步測試故在一般程式main中直接調用都很正常,不知道是什麽原因造成的。
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\struts2-core-2.1.8.1.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\commons-logging-1.0.4.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\freemarker-2.3.15.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\ognl-2.7.3.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\xwork-core-2.1.6.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\commons-fileupload-1.2.1.jar
E:\java\hibernate\hibernate-distribution-3.6.5.Final-dist\hibernate-distribution-3.6.5.Final\hibernate3.jar
E:\java\spring\spring-hibernate3.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.aop-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.asm-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.aspects-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.beans-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.context.support-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.context-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.core-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.expression-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.instrument-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.jdbc-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.jms-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.orm-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.oxm-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.test-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.transaction-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.web.portlet-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.web.servlet-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.web.struts-3.0.2.RELEASE.jar
E:\java\spring\spring-framework-3.0.2.RELEASE-with-docs\spring-framework-3.0.2.RELEASE\dist\org.springframework.web-3.0.2.RELEASE.jar
E:\java\mysql_jdbc\mysql.jar
E:\java\dom4j\dom4j-1.6.1\dom4j-1.6.1\dom4j-1.6.1.jar
E:\java\hibernate\hibernate-distribution-3.6.5.Final-dist\hibernate-distribution-3.6.5.Final\lib\required\slf4j-api-1.6.1.jar
E:\java\commons dbcp\commons-dbcp-1.2.jar
E:\java\commons pool\commons-pool-1.5.jar
E:\java\hibernate\hibernate-distribution-3.6.5.Final-dist\hibernate-distribution-3.6.5.Final\lib\required\commons-collections-3.1.jar
E:\java\hibernate\hibernate-distribution-3.6.5.Final-dist\hibernate-distribution-3.6.5.Final\lib\required\antlr-2.7.6.jar
E:\java\hibernate\hibernate-distribution-3.6.5.Final-dist\hibernate-distribution-3.6.5.Final\lib\required\jta-1.1.jar
E:\java\hibernate\hibernate-distribution-3.6.5.Final-dist\hibernate-distribution-3.6.5.Final\lib\jpa\hibernate-jpa-2.0-api-1.0.0.Final.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\commons-lang-2.3.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\aopalliance-1.0.jar
E:\java\aspectjweaver\aspectjweaver-1.5.2.jar
E:\java\Struts\struts-2.1.8.1-all\struts-2.1.8.1\lib\struts2-spring-plugin-2.1.8.1.jar

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <welcome-file-list>
                <welcome-file>login.jsp</welcome-file>
        </welcome-file-list>
        <filter>
                <filter-name>openSessionInView</filter-name>
                <!--
                        重寫OpenSessionInViewFilter使用之由Spring默認Hibernate只讀 改為可不控制
                        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
                -->
                <filter-class>com.util.hibernate.MyOpenSessionInViewFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>openSessionInView</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <!-- 設定Spring配置 -->
        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <filter>
                <filter-name>struts2</filter-name>
                <!-- 2.1.8之前版本org.apache.structs2.dispatcher.FilterDispatcher -->
                <!-- 2.1.8之后版本(含)org.apach......StrutsPrepareAndExecuteFilter-->
                <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>
        <!-- 過濾字符 -->
        <filter>
                <filter-name>EncodingFilter</filter-name>
                <filter-class>com.util.hibernate.CharacterEncodingFilter</filter-class>
                <init-param>
                        <param-name>encoding</param-name>
                        <param-value>UTF-8</param-value>
                </init-param>
        </filter>

        <!-- spring listener -->
        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
</web-app>

论坛徽章:
0
2 [报告]
发表于 2011-07-14 16:14 |只看该作者
先看看 配置是否有問題 謝謝
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP