本文介绍了Struts未处理的异常 - 未定义行为的结果 - Struts Spring&休眠集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我正在实现Struts Spring& Hibernate集成在线考试项目。但是,当我在JSP页面中提交值时,它会引发以下错误:


$ b Struts问题报告

  Struts检测到未处理的异常:

消息:
未定义行为的结果onlineexam.action.RegistrationAction和结果
成功

Stacktraces

 没有针对操作定义的结果onlineexam.action.RegistrationAction和结果成功
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:363 )
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony .xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvoca tion.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:251)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept( AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2。 interceptor.parametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.in voke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
com。 opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.s truts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept( ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony。 xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActi onInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:164)
com.opensymphony。 xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation。 java:236)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ExceptionMappingI nterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java: 52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina。 core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.Authentic atorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve。 java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
org.apache。 coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:1852)
java.util.concurrent。 ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:724)

我附加了RegistrationAction.java,如下所示:

RegistrationAction.java

  public class RegistrationAction extends ActionSupport {

private UserRegistrationService userRegistrationService;
$ b $ public UserRegistrationService getUserRegistrationService(){
return userRegistrationService;
}

public void setUserRegistrationService(
UserRegistrationService userRegistrationService){
this.userRegistrationService = userRegistrationService;
}

private String first_Name;
private String last_Name;
私人字符串emailid;
私人字符串passWord;
私人字符串性别;
private int dateofbirth;
private int phoneNo;
private float user_experience;

@ManyToOne(fetch = FetchType.LAZY,targetEntity = UserDetails.class)
@JoinColumn(name =user_id)
private int user_id;
private String addr_line1;
private String addr_line2;
private String addr_line3;
私人字符串城市;
private int zipcode;
私有字符串状态;
私人字符串国家;
$ b $ public PublicAction(){
}

//生成的getter和setters

public String SaveUserDetails(){
String forward =SUCCESS;

尝试{
UserDetails s = new UserDetails();
s.setFirst_name(getFirst_Name());
s.setLast_name(getLast_Name());
s.setEmail(getEmailid());
s.setPassword(getPassWord());
s.setGender(getGender());
s.setDob(getDateofbirth());
s.setPhone(getPhoneNo());
s.setExperience(getUser_experience());

设置< UserAddress> address = new HashSet< UserAddress>(0);
setUserAddress(address);
userRegistrationService.saveUserRegistration(s);

} catch(Exception ex){
forward =ERROR;
}
前进; }
$ b $ protected void setUserAddress(Set< UserAddress> address)throws Exception {
UserAddress ad = new UserAddress();
ad.setAddr_line1(getAddr_line1());
ad.setAddr_line2(getAddr_line2());
ad.setAddr_line3(getAddr_line3());
ad.setCity(getCity());
ad.setZipcode(getZipcode());
ad.setState(getState());
ad.setCountry(getCountry());

address.add(ad); }
}

MainLayout.jsp

 <%@ taglib uri =tiles-jsp.tldprefix =tiles%> 
< html>
< head>
< meta HTTP-EQUIV =Content-Typecontent =text / htmlcharset =ISO-8859-1>
< title> ISAS:< tiles:insertAttribute name =title/>< / title>
< style type =text / css>
< / style>
< / head>
< body>
<! - Header - >
< tiles:insertAttribute name =headerignore =true/>

< div class =noprint>
< table>
< tr valign =top>
< td width = 10px>< / td>
< td vAlign = top width =99%>

< div>
< span>< tiles:insertAttribute name =pageHeading/>< / span>
< / div>
< / td>
< / tr>
< / table>
< / div>
<! - 导航 - >
< div>
< table>
< tr>
< td vAlign = top align =centerwidth =100%>
< tiles:insertAttribute name =navignore =true/>
< / td>
< / tr>
< / table>
< / div>

<! - Body Content - >
< table>
< tbody>
< tr>
< td width = 10px>< / td>
< td vAlign = top align =centerwidth =99%>
< tiles:insertAttribute name =contentignore =true/>
< / td>
< / tr>
< / tbody>
< / table>
< table>
< tbody>
< tr>
< td vAlign = top align =centerwidth =99%>
< br>
< / td>
< / tr>
< / tbody>
< / table>
< tiles:insertAttribute name =footerignore =true/>
< / body>
< / html>

我不知道问题所在。运行这个时,它不会在MySQL数据库中插入值...我对这个主题很陌生...请帮助我的朋友......无论如何感谢提前的朋友...... !!!

解决方案

这是错误的: String forward =SUCCESS;



正确的字符串是成功;

 字符串转发=成功; 

并且,由于您正在扩展ActionSupport,因此您可以使用常量SUCCESS来防止将来的语法错误。 / p>

  String forward = SUCCESS; 

Struts.xml中必须存在相同的映射。如果你在Struts.xml中输入SUCCESS,那就去改变它,以防止未来的麻烦......



PS:与ERROR相同应该是error 。


Actually I'm working on implementing Struts Spring & Hibernate Integration on online Exam project. But While I'm submitting the values in the JSP page, it throws me the following error:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:   
No result defined for action onlineexam.action.RegistrationAction and result 
success

Stacktraces

No result defined for action onlineexam.action.RegistrationAction and result success
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:363)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:251)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    java.lang.Thread.run(Thread.java:724)

I have attached the RegistrationAction.java as follows

RegistrationAction.java

public class RegistrationAction extends ActionSupport {

    private UserRegistrationService userRegistrationService;

    public UserRegistrationService getUserRegistrationService() {
        return userRegistrationService;
    }

    public void setUserRegistrationService(
            UserRegistrationService userRegistrationService) {
        this.userRegistrationService = userRegistrationService;
    }

    private String first_Name;
    private String last_Name;
    private String emailid;
    private String passWord;
    private String Gender;
    private int dateofbirth;
    private int phoneNo;
    private float user_experience;

    @ManyToOne(fetch=FetchType.LAZY, targetEntity=UserDetails.class)
    @JoinColumn(name="user_id")
    private int user_id;
    private String addr_line1;
    private String addr_line2;
    private String addr_line3;
    private String city;
    private int zipcode;
    private String state;
    private String country;

    public RegistrationAction() {
    }

// generated getters and setters

    public String SaveUserDetails() {
        String forward = "SUCCESS";

        try {
            UserDetails s = new UserDetails();
            s.setFirst_name(getFirst_Name());
            s.setLast_name(getLast_Name());
            s.setEmail(getEmailid());
            s.setPassword(getPassWord());
            s.setGender(getGender());
            s.setDob(getDateofbirth());
            s.setPhone(getPhoneNo());
            s.setExperience(getUser_experience());

            Set<UserAddress> address = new HashSet<UserAddress>(0);
            setUserAddress(address);
            userRegistrationService.saveUserRegistration(s);

        } catch (Exception ex) {
            forward = "ERROR";
        }
        return forward;   }

    protected void setUserAddress(Set<UserAddress> address) throws Exception {
           UserAddress ad = new UserAddress();
           ad.setAddr_line1(getAddr_line1());
           ad.setAddr_line2(getAddr_line2());
           ad.setAddr_line3(getAddr_line3());
           ad.setCity(getCity());
           ad.setZipcode(getZipcode());
           ad.setState(getState());
           ad.setCountry(getCountry());

           address.add(ad); }
}

MainLayout.jsp

<%@ taglib uri="tiles-jsp.tld" prefix="tiles"%>
<%@ taglib uri="struts-tags.tld" prefix="struts"%>
<html>
<head>
  <meta HTTP-EQUIV="Content-Type" content="text/html" charset="ISO-8859-1">
  <title>ISAS:<tiles:insertAttribute name="title"/></title>
  <style type="text/css">
  </style>
</head>
<body>
    <!-- Header -->
    <tiles:insertAttribute name="header" ignore="true"/>

    <!-- Page Header -->
<div class="noprint">
    <table>
      <tr valign="top">
        <td width=10px></td>
        <td vAlign=top width="99%">         

                <div>
                     <span><tiles:insertAttribute name="pageHeading"/></span>
                </div>
         </td>
       </tr>
    </table>
</div>  
    <!-- Navigation -->
<div>
    <table>
    <tr>
    <td vAlign=top align="center" width="100%"> 
    <tiles:insertAttribute name="nav" ignore="true"/>
    </td>
    </tr>
    </table>    
</div>

    <!-- Body Content -->
    <table>
     <tbody>
      <tr>              
        <td width=10px></td>
        <td vAlign=top align="center" width="99%">  
            <tiles:insertAttribute name="content" ignore="true"/>
        </td>
      </tr>
     </tbody>
    </table>
    <table>
     <tbody>
      <tr>
        <td vAlign=top align="center" width="99%">  
            <br>
        </td>
      </tr>
     </tbody>
    </table>
    <!-- Footer -->
    <tiles:insertAttribute name="footer" ignore="true"/>
</body>
</html>

I don't know where the problem is. While running this, it doesn't inserting the values in the mysql DB... I'm very new to this topic...Please Help me Friends... Anyway thanks in Advance friends...!!!

解决方案

This is wrong: String forward = "SUCCESS";

The right String is "success";

String forward = "success";

and, since you are extending ActionSupport, you can use the constant SUCCESS to prevent future syntax errors.

String forward = SUCCESS;

The same mapping has to exist in Struts.xml. If you put "SUCCESS" in Struts.xml, go and change it, to prevent future headaches...

P.S: Same for "ERROR" that should be "error".

这篇关于Struts未处理的异常 - 未定义行为的结果 - Struts Spring&amp;休眠集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 02:30