使用json来实现用户注册的用户名验证
必须通过操作数据库来执行
在SSH框架中使用Action调DAO来实现
这样结合json怎么用下面是我目前的配置文件struts.xml
====================================
<package name="json" extends="json-default">
<action name="User" class="com.online.action.UserAction">
<result type="json"></result>
</action>
applicationCotext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!--首先建数据库sample,建表users,开启mysql服务-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/online</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>123</value></property>
</bean> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/online/dao/Login.hbm.xml</value>
</list>
</property>
</bean> <bean id="loginDAO" class="com.online.dao.LoginDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="accountService" class="com.online.service.AccountService">
<property name="loginDAO">
<ref bean="loginDAO" />
</property>
</bean>
<bean name="/Account"
class="com.online.action.AccountAction">
<!-- RegisterAction中住的service的名称 -->
<property name="accountService">
<ref bean="accountService" />
</property>
</bean>
<bean name="/User"
class="com.online.action.UserAction">
<!-- RegisterAction中住的service的名称 -->
<property name="accountService">
<ref bean="accountService" />
</property>
</bean>
</beans>++++++++++++++++++++++++++++++++++++++++++++++++++++启动tomcat时报错-----〉org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/User' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'accountService' of bean class [com.online.action.UserAction]: Bean property 'accountService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'accountService' of bean class [com.online.action.UserAction]: Bean property 'accountService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:793)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
我的配置有问题。需要大虾们的帮忙
必须通过操作数据库来执行
在SSH框架中使用Action调DAO来实现
这样结合json怎么用下面是我目前的配置文件struts.xml
====================================
<package name="json" extends="json-default">
<action name="User" class="com.online.action.UserAction">
<result type="json"></result>
</action>
applicationCotext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!--首先建数据库sample,建表users,开启mysql服务-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/online</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>123</value></property>
</bean> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/online/dao/Login.hbm.xml</value>
</list>
</property>
</bean> <bean id="loginDAO" class="com.online.dao.LoginDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="accountService" class="com.online.service.AccountService">
<property name="loginDAO">
<ref bean="loginDAO" />
</property>
</bean>
<bean name="/Account"
class="com.online.action.AccountAction">
<!-- RegisterAction中住的service的名称 -->
<property name="accountService">
<ref bean="accountService" />
</property>
</bean>
<bean name="/User"
class="com.online.action.UserAction">
<!-- RegisterAction中住的service的名称 -->
<property name="accountService">
<ref bean="accountService" />
</property>
</bean>
</beans>++++++++++++++++++++++++++++++++++++++++++++++++++++启动tomcat时报错-----〉org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/User' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'accountService' of bean class [com.online.action.UserAction]: Bean property 'accountService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'accountService' of bean class [com.online.action.UserAction]: Bean property 'accountService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:793)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
我的配置有问题。需要大虾们的帮忙
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货