【JavaEE-bug集合】Exception occurred during processing request:

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/skybboy/article/details/79947557

出现这个错误我的是由于在使用struts2框架 时候使用模型驱动封装页面传来的参数时,没有给对象生成get set方法,给忘记了,还要实现getModel方法,返回对象,并且struts.xml中配置的action方法一定要存在于Action中

模型驱动封装参数正确的Action如下:

package cn.itheima.param;  
  
import java.util.Date;  
import java.util.Map;  
  
import com.opensymphony.xwork2.ActionContext;  
import com.opensymphony.xwork2.ActionSupport;  
//struts2如何获得参数  
//属性驱动获得参数  
import com.opensymphony.xwork2.ModelDriven;  
  
import cn.itheima.domain.User;  
//3.模型驱动  
//缺陷:只能返回一个对象  
//1->实现接口  
public class DemoAction1 extends ActionSupport implements ModelDriven<User>{  
    /* 
     * 页面设置<input type='text' name='name'/> 页面跟以前一样 
     * */  
    private User user=new User();//3->准备一个user对象 需要创建出对象来  
    public User getUser() {  
        return user;  
    }  
    public void setUser(User user) {  
        this.user = user;  
    }  
    public String execute() throws Exception {  
          
        return SUCCESS;  
    }  
      
    //2->实现方法返回对象  
    @Override  
    public User getModel() {  
        // TODO Auto-generated method stub  
        return user;  
    }  
      
}  

配置struts.xml (注意包名和方法名)

<package name="crm" namespace="/" extends="struts-default">
		<action name="CustomerAction_*" class="cn.itheima.web.action.CustomerAction" method="{1}">
			<result name="list" type="dispatcher">/jsp/customer/list.jsp</result>
			<result name="toList" type="redirectAction">
				<param name="actionName">CustomerAction_list</param>
				<param name="namespace">/</param>
			</result>
		</action>
		
		<action name="UserAction_*" class="cn.itheima.web.action.UserAction" method="{1}">
			<result name="toHome" type="redirect">/index.htm</result>
		</action>
	</package>

 

阅读更多

Exception occurred during processing request: null java.lang.NullPointerExceptio

01-02

@SuppressWarnings("serial")rnpublic class RoleAction extends ActionSupportrn private RoleService roleService;rn private Yuangong yuanGong;rn private ListyuangList = new ArrayList(0);rn private String keyWord;rnrnrn public RoleService getRoleService() rn return roleService;rn rnrn public void setRoleService(RoleService roleService) rn this.roleService = roleService;rn rn rnrn public Yuangong getYuanGong() rn return yuanGong;rn rnrn public void setYuanGong(Yuangong yuanGong) rn this.yuanGong = yuanGong;rn rnrn public List getYuangList() rn return yuangList;rn rnrn public void setYuangList(List yuangList) rn this.yuangList = yuangList;rn rnrn public String getKeyWord() rn return keyWord;rn rnrn public void setKeyWord(String keyWord) rn this.keyWord = keyWord;rn rnrn /**rn * 添加角色rn * @returnrn */rn public String addRole()rn Yuangong yg = roleService.insertYG(yuanGong);rn if(yg!=null)rn return "success";rn rn return "input";rnrnrnrnrnpublic interface RoleService rn public Yuangong insertYG(Yuangong yuanGong);rn public Yuangong deleteYG(Yuangong yuanGong);rn public Yuangong upateYG(Yuangong yuanGong);rn public Yuangong findByYgBH(String ygbh);rn public List findByKeyWord(String keyWord);rnrnrnrnrnpublic class RoleServiceImpl implements RoleService rn rn private RoleDao roleDao;rnrn public void setRoleDao(RoleDao roleDao) rn this.roleDao = roleDao;rn rnrn @Overridern public Yuangong insertYG(Yuangong yuanGong) rn rn return roleDao.insert(yuanGong);rn rnrnrnrnpublic interface RoleDao rn rn public Yuangong insert(Yuangong yuanGong);rn public Yuangong update(Yuangong yuanGong);rn public Yuangong delete(Yuangong yuanGong);rn public Yuangong findByYgBH(String ygbh);rn public List findByKeyWord(String keyWord);rn rn rn rnrnrnrnpublic class RoleDaoImpl implements RoleDao rnrn /**rn * 插入员工信息rn * @param yuanGongrn * @returnrn */rn @SuppressWarnings("unused")rn @Overridern public Yuangong insert(Yuangong yuanGong) rn rn //创建连接对象rn DBMangger dbMangger = new DBMangger();rn //SQL语句rn String sql = "insert into YuanGong values("+yuanGong.getYgbh()+","+yuanGong.getYgxm()+"," +rn ""+yuanGong.getYgzh()+","+yuanGong.getYgmm()+","+yuanGong.getYgmm()+","rn +yuanGong.getBmbh()+","+yuanGong.getStatus()+",sysdate)";rn rn int i = dbMangger.executeUpdate(sql);rn if(i>0)rn System.out.println("执行成功");rn return yuanGong;rn elsern System.out.println("保存失败");rn return null;rn rn rn rn rnrnrnrn

STRUTS的问题 Exception occurred during processing request: null

05-10

20130510 09:48:47,170 ERROR [org.apache.struts2.dispatcher.Dispatcher] Exception occurred during processing request: nullrnjava.util.ConcurrentModificationExceptionrn at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)rn at java.util.ArrayList$Itr.next(ArrayList.java:791)rn at org.apache.struts2.json.JSONWriter.array(JSONWriter.java:482)rn at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:158)rn at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)rn at org.apache.struts2.json.JSONWriter.map(JSONWriter.java:437)rn at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:154)rn at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:134)rn at org.apache.struts2.json.JSONWriter.write(JSONWriter.java:102)rn at org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:116)rn at org.apache.struts2.json.JSONResult.createJSONString(JSONResult.java:197)rn at org.apache.struts2.json.JSONResult.execute(JSONResult.java:171)rn at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:271)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)rn at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)rn at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)rn at java.lang.Thread.run(Thread.java:722)

没有更多推荐了,返回首页