当前位置:编程学习 > JAVA >>

ssh结构,action接收不到页面传过来的数据applicationContext.xml和struts.xml

applicationContext.xml代码

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-2.0.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-2.0.xsd 
    http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@localhost:1521:DEMO" />
<property name="username" value="study" />
<property name="password" value="study" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/hhh/entity/Parts.hbm.xml</value>
                <value>com/hhh/entity/Person.hbm.xml</value>
                <value>com/hhh/entity/SsSort1.hbm.xml</value>
</list>
</property>
    </bean> 
    
<!-- 配置事务管理器,并注入sessionFactory -->
        <bean name="transactionManager" 
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
   
    <!-- 事务拦截器 -->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 事务连接器 需要注入一个事务管理器 -->
<property name="transactionManager" ref="transactionManager" />
<!-- 事务的传播属性 -->
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<!--BeanNameAutoProxyCreator 该bean无需被引用 ,所以没有id属性, 配置声明式事务 -->
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<!-- 指定对哪些ben生成业务代理 事务的边界 -->
<property name="beanNames">
<list>
<value>business</value>
<value>pagerHelper</value>
</list>
</property>


<!-- 事务拦截 -->
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>


<bean id="hibernateDao" class="com.hhh.hibernateImp.HibernateMySqlImp">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="business" class="com.hhh.businessImp.BusinessImp">
<property name="hibernateDao">
<ref bean="hibernateDao" />
</property>
</bean>
</beans>

struts.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" 
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<package name="partsmanagement" namespace="/" extends="json-default">
<action name="TreeAction" class="com.hhh.action.TreeAction">
<result>/data.jsp</result>
</action>
<action name="ReadPartsAction" class="com.hhh.action.ReadPartsAction">
    <result type="json"></result>
</action>
<action name="CheckPartsAction" class="com.hhh.action.CheckPartsAction">
    <result type="json"></result>
</action>
<action name="AddPartsAction" class="com.hhh.action.AddPartsAction">
    <result type="json"></result>
</action>
</package>
</struts>
    



CheckPartsAction和AddPartsAction这两个action调不到,ReadPartsAction可以把信息读出来。求大神拍砖 SSH xml action --------------------编程问答-------------------- 我想知道报的错是什么。能不能把错误也贴出来。
还有,你这是单独的用struts的action是吧。不想让Spring帮你注入。 --------------------编程问答--------------------
引用 1 楼 endendsixteen 的回复:
我想知道报的错是什么。能不能把错误也贴出来。
还有,你这是单独的用struts的action是吧。不想让Spring帮你注入。


是的我只想用struts的action。另外,我根本没报错,这两个action根本就没跳过去 --------------------编程问答--------------------
引用 1 楼 endendsixteen 的回复:
我想知道报的错是什么。能不能把错误也贴出来。
还有,你这是单独的用struts的action是吧。不想让Spring帮你注入。

这是我页面用到的js文件

Ext.onReady(function() {
Ext.QuickTips.init();
// 输入验证框不通过是时,消息提示方式有四种:qtip,title,under,side
Ext.form.Field.prototype.msgTarget = 'under';
var requiredMark = '<span style="color:red">*</span>';
var isPersonNameOK = true; // 先定义个全局变量

var IsExsit = false;// 此变量一定要在方法外面定义
function ReturnValue(ok) {// 此方法必须放CheckUserName里面。
IsExsit = ok;
}
function checkName() { // 检查用户名是否存在
var username = Ext.get('parts.partsname').dom.value;
Ext.Ajax.request({
url : 'CheckPartsAction',
params : {
name : username
},
success : function(response, options) {
var data = Ext.util.JSON.decode(response.responseText);
if (data.success == true) {
ReturnValue(true);
} else {
ReturnValue(false);// 不能在success里面直接return
}
}
});
return IsExsit;
}

var simple = new Ext.FormPanel({
frame : true,
layout : "form",
title : "添加配件信息",
// monitorValid : true,
labelWidth : 70,
renderTo : "form",
xtype : 'fieldset',

collapsible : true,
labelAlign : 'right',
method : 'post',
autoHeight : true,
width : 330,
defaultType : 'textfield',
defaults : {
width : 200
},
items : [{
xtype : "textfield",
fieldLabel : requiredMark+ '配件名称编码',
name : 'parts.partsnameid',
allowBlank : false
                }, {
             xtype : "textfield",
             fieldLabel : requiredMark + '配件名称',
             name : 'parts.partsname',
             
             allowBlank : false,
             id:'parts.partsname',
                 //validator : CheckName,
             validatorEvent : 'blur',
             invalidText : "配件名称已经存在",
             emptyText : "请输入配件名称",
             validator : function(thisText) {
         if (thisText != '') {
                Ext.Ajax.request({
        url : 'CheckPartsAction',
        method : 'post',
        params : {
         name : thisText
         },
success : function(response,
options) {
var data = Ext.util.JSON
.decode(response.responseText);//获取action里的rs json

/*alert(Ext.util.JSON.decode(response.responseText));*/
if (data.success == false) {
isPersonNameOK = false;
   Ext
.getCmp('parts.partsname')
.markInvalid('配件名称已经存在');
} else {
isPersonNameOK = true;
  Ext.getCmp('parts.partsname')
.clearInvalid();
}
}
});
}
return isPersonNameOK;
}
},{
xtype:"textfield",
fieldLabel : requiredMark+'型号名称',
name:'parts.xinghaoname',
allowBlank:false
},{
xtype:"textfield",
fieldLabel : requiredMark+'配件型号',
name:'parts.partsxinghao',
allowBlank:false
},{
xtype:"textfield",
fieldLabel : requiredMark+'最大编号',
name:'parts.mingpaiid',
allowBlank:false
},{
xtype:"textfield",
fieldLabel : requiredMark+'配件工程师',
name:'parts.partsengineer',
    allowBlank:false
},{
xtype:"textfield",
fieldLabel : requiredMark+'出厂日期',
name:'parts.outdate',
allowBlank:false
},{
xtype:"textfield",
fieldLabel : requiredMark+'注册日期',
name:'parts.registertime',
allowBlank:false
},{
xtype:"textfield",
fieldLabel : requiredMark+'库名称',
name:'parts.libraryname',
allowBlank:false
}],
// 增加按钮
buttons : [{
text : '确定',
handler : function() {
if (!simple.getForm().isValid())
return;
simple.getForm().submit({
waitMsg : "正在提交数据……",
waitTitle : "提示",
url : "AddPartsAction.action",
method : "post",
success : function(form, action) {
Ext.Msg.alert("提示",
action.result.message);
},
failure : function(form, action) {
Ext.Msg.alert("提示",
action.result.message);
}
});

}

}, {
text : '取消',
handler : function() {
simple.getForm().reset();
}

}]

}

);

}

);


运行的时候,会有如下错误:

无论你输入什么,都会显示“配件名称已存在”。




--------------------编程问答-------------------- 如果输什么都提示已存在,那就很有可能是你的验证出错 --------------------编程问答--------------------
引用 4 楼 a631855639 的回复:
如果输什么都提示已存在,那就很有可能是你的验证出错


是验证错了,但是直接跳不到action是怎么回事? --------------------编程问答-------------------- 神啊,帮我看看吧
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,