2

实际上,我正在为在线考试项目实施 Struts Spring & Hibernate Integration。但是当我在 JSP 页面中提交值时,它会抛出以下错误:

Struts 问题报告

Struts has detected an unhandled exception:

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

堆栈跟踪

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)

我已附加 RegistrationAction.java 如下

注册动作.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); }
}

主布局.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>

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

4

1 回答 1

1

这是错误的:String forward = "SUCCESS";

正确的字符串是"success"

String forward = "success";

而且,由于您正在扩展 ActionSupport,您可以使用常量 SUCCESS 来防止将来出现语法错误。

String forward = SUCCESS;

Struts.xml 中必须存在相同的映射。如果您在 Struts.xml 中添加“SUCCESS”,请去更改它,以防止将来出现头疼...

PS:与“错误”相同,应该是“错误”。

于 2013-09-12T14:12:52.510 回答