慕娘8172444
2016-12-16 19:30
<!----------------struts.xml ----------------->
<package name="ssh" extends="struts-default" namespace="/">
<action name="product_*" class="productAction" method="{1}">
</action>
</package>
<!---------------- applicationContext.xml ----------------->
<!-- 配置Action的类 -->
<bean id="productAction" class="action.ProductAction" scope="prototype">
<!-- 手动注入Service -->
<property name="priductService" ref="productService"></property>
</bean>
<!-- 配置业务层的类 -->
<bean id="productService" class="service.ProductService">
<property name="productDao" ref="productDao"/>
</bean>
<!-- 配置Dao类 -->
<bean id="productDao" class="dao.ProductDao"> </bean>
<!----------------------------jsp----------------------->
<s:form action="product_save" method="post" namespace="/" theme="simple">
<table border="1" width="400">
<tr>
<td>商品名称</td>
<td><s:textfield name="pname"/></td>
</tr>
<tr>
<td>商品价格</td>
<td><s:textfield name="price"></s:textfield></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="添加"/></td>
</tr>
</table>
</s:form>
<!-----------------------exection----------------->
org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
root cause
java.lang.NullPointerException
org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:827)
org.apache.struts2.components.UIBean.end(UIBean.java:535)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.addProduct_jsp._jspx_meth_s_005ftextfield_005f0(addProduct_jsp.java:177)
org.apache.jsp.addProduct_jsp._jspx_meth_s_005fform_005f0(addProduct_jsp.java:133)
org.apache.jsp.addProduct_jsp._jspService(addProduct_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
<!-- 配置Action的类 -->
<bean id="productAction" class="action.ProductAction" scope="prototype">
<!-- 手动注入Service -->
<property name="priductService" ref="productService"></property>
</bean>
<!-- 配置业务层的类 -->
<bean id="productService" class="service.ProductService">
<property name="productDao" ref="productDao"/>
</bean>
<!-- 配置Dao类 -->
<bean id="productDao" class="dao.ProductDao"> </bean>
class要写全类名
空指针异常最主要的原因一般为类没有注入到spring中,检查set写了没
基于SSH实现员工管理系统之框架整合篇
49831 学习 · 344 问题
相似问题