求助各位大神!我刚开始入门,写了一个信息管理系统,用的Spring+Struts2+myBatis+Bootstrap界面。
我实现增.删.查的功能都正常,就改功能不行。但是,我改功能的代码和增功能的代码几乎一模一样。但是就是报错,我打调试信息看,发现增功能,可以正常从前台传参到Bean,再主动跳转到Action里面的add(),但是改功能就是不行,只能走到传参到Bean,但是没有跳转到update(),因为不跳转到update()处理,所以就报图一的错误。页面只有赋值取值,没有update()响应。
问题的关键就在于,add.jsp和update.jsp除了action关联的函数,<input>标签一个没有value先取值,一个有value取值之外,没有任何区别,真是没有区别,我还怕写错了,专门用BeyondCompare比对了,就<form action="">这个地方不一样,后附BC对比图。我试着把<form>里面的action从update改成add,也不行,改过之后就成add()不响应了,改成谁,谁不响应。
萌新学识疏浅,实在实在找不到哪里写错了,各位大神能不能指导一下!谢谢!
(如果放错版区了,还请版主帮忙更正一下,谢谢版主!)
代码如下:
BiYeXinXiAction:
..........
public String add() {
result = biYeXinXiService.insert(biYeXinXi);
backurl = "biYeXinXi/add.jsp";
return "result-jsp";
}
public String update() {
result = biYeXinXiService.update(biYeXinXi);
backurl = "front/biYeXinXi_intoUpdate.action?biYeXinXi.biyedanganid=" + biYeXinXi.getBiyedanganid();
return "result-jsp";
}
..........
add.jsp:写不下了,见附件图
update.jsp:写不下了,见附件图
struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.locale" value="zh_CN" />
<constant name="struts.multipart.maxSize" value="20971520" />
<constant name="struts.action.extension" value="action,do," />
<package name="front" extends="json-default" namespace="/front">
<action name="biyexinxi_*" class="biYeXinXiAction" method="{1}">
<result name="result-json" type="json">
<param name="root">result</param>
</result>
<result name="result-jsp">/biyexinxi/result.jsp</result>
<result name="index">/biyexinxi/index.jsp</result>
<result name="intoUpdate">/biyexinxi/update.jsp</result>
</action>
..............
springconfig.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"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>org.logicalcobwebs.proxool.ProxoolDriver</value>
</property>
<property name="url">
<value>proxool.db</value>
</property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="typeAliasesPackage" value="com.bysmis" />
<property name="plugins">
<list>
<bean class="com.core.code.util.PagingPlugin">
<property name="dialect" value="mysql" />
</bean>
</list>
</property>
</bean>
<bean name="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.bysmis.persistence" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="myDataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
bean.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"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:component-scan base-package="com.bysmis" />
</beans>