解决办法
1。可能是在action和biz中没写set方法
private NewsBiz newsBiz; public void setNewsBiz(NewsBiz newsBiz) { this.newsBiz = newsBiz; }
private NewsDao newsDao; public void setNewsDao(NewsDao newsDao) { this.newsDao = newsDao; }
2。applicationContext中没配置
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" /> <property name="configLocation" value="classpath:hibernate.cfg.xml" /> <property name="mappingResources"> <list> <value>com/accp/pojo/News.hbm.xml</value> <value>com/accp/pojo/Vacation.hbm.xml</value> <value>com/accp/pojo/ExceptionOrder.hbm.xml</value> </list> </property> </bean>
<!-- News dao --> <bean id="NewsDaoImpl" class="com.accp.dao.impl.NewsDaoImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- biz --> <bean id="NewsBizImpl" class="com.accp.biz.impl.NewsBizImpl"> <property name="newsDao" ref="NewsDaoImpl" /> </bean> <!-- action --> <bean id="NewsAction" class="com.accp.action.NewsAction" scope="prototype"> <property name="newsBiz" ref="NewsBizImpl" /> </bean>
3.status中class写了全路径
错误代码
<action name="new*" class="com.accp.action.NewsAction" method="{1}"> <result name="selectFirstPage">/news.jsp</result> <result name="selectNextPage">/news.jsp</result> <result name="newsupdate" type="redirectAction">newselectFirstPage</result> <result name="add" type="redirectAction">newselectFirstPage</result> <result name="delete" type="redirectAction">newselectFirstPage</result> <result name="updatejsp">/news_update.jsp</result> <result name="error">/error.jsp</result> </action>
正确代码
<!--selectFirstPage--> <action name="new*" class="NewsAction" method="{1}"> <result name="selectFirstPage">/news.jsp</result> <result name="selectNextPage">/news.jsp</result> <result name="newsupdate" type="redirectAction">newselectFirstPage</result> <result name="add" type="redirectAction">newselectFirstPage</result> <result name="delete" type="redirectAction">newselectFirstPage</result> <result name="updatejsp">/news_update.jsp</result> <result name="error">/error.jsp</result> </action>