The solution to the exception of No result defined for action in struts2



When I encountered this problem (No result defined for action....input), this article gave me some inspiration. I felt that the article was useful for reference, so I quoted it as a note for future reference.

http://www.cnblogs.com/aigeileshei/articles/5252319.html

quote

Last night, I thought of a function that I didn't do, so I wanted to do it! Since this function has been done before, it was written soon, so I deployed it and debug tomcat! However, during the test, it always reported No result defined for action abnormality. After checking for an hour, and taking out the code written before for comparison, I still did not find the cause of the error, so I had to give up! I got up this morning and started to search for this on Google. Although there are many such mistakes on the Internet, but I have not been able to solve this problem after reading a lot, so I added a result with the name in the result as input according to the online post:
<result name= "input">/WEB-INF/page/error/error.jsp</result> 
, also added a
<s:debug></s:debug> 
code in error.jsp, because I don't know struts2 Great, I didn't see anything from the stacktrace of debug, so I could only continue to search on Google, and then tinker in my own code, and found that in the manage/store/storeType_online (using wildcards) to be executed, in The online method in StoreAction does not have a function, but another method of the class that is executed
public String getStoreDetail() { 
        store = storeService.find(storeid); 
        return "storedetail"; 
    } 
Since the parameter of storeid was not passed, an error was reported, so I commented out the above method. At this time, I did the test and entered the error.jsp page. I didn't see any problems from the stack. I went to the Internet and searched for "struts2 method not executed". I saw the following text in the page http://blog.csdn.net/gavin812428144/archive/2010/03/27/5422220.aspx I found the following text when I submitted the form
today . The execute() method is not executed, but validate() is executed, and no error is reported. After execution, it exits directly, and the program does not enter execute(). 
 
      After several debugging, it is found that the resultCode returned by validate() is INPUT, indicating that the verification has not passed. What is the reason that the verification failed?! I was depressed for a long time, and finally suddenly remembered that there was an input of type="file" in the form I submitted, that is, I was going to upload a file, but I forgot to put the form's input Change the enctype attribute to "multipart/form-data". It seems that a problem has been found, so try again quickly. The result is as expected. It is this problem that caused the form submission to fail and execute() to not be executed. 
 
      If you encounter similar problems, you may wish to take a look at the enctype of your form. I hope this experience will be useful to you. 
, only to know that the result of INPUT is the return result that has not passed the verification (the foundation is not well grasped, it is a waste of time). So I suspect that the data submitted by the form has not passed the default verification of struts2, so I can only search on Google and find this page http://blog.csdn.net/yby0260/archive/2010/08/18/5822312.aspx:
When we use the validation framework that comes with struts2 to validate form fields, we need to display error messages on the page. Generally, we add the <s:fielderror/> tag to the page. And <s:fielderror/> will be parsed into the form of <ul><li><span>error message</span></li></ul>, so that the display of the error message can only be displayed in the validation field Above or below, and what we need is often to display the error message on the right side of the validation field. 
, so I added <s:fielderror/> to the error.jsp page, and then I saw the error message. It turned out to be a hidden input in storelist.jsp
<input type="hidden" name="currentPage" value=" The value verification of ${currentPage}"/> 
is invalid, so I looked at the previous code and found that there is no value="${currentPage}" attribute, so after removing this attribute, test again, it is normal. Finally solved it, it's not easy...
    To sum up: When encountering the problem of No result defined for action, first check whether it is a problem of validate. In action, set a breakpoint to see if it is executed (note, To use debug, tomcat must be started in debug mode, and it is recommended to start in debug mode during development), add an INPUT return result to see, and output the verification information in the corresponding page. If it is not the problem of validate, then look at the page element when there is renaming, but the corresponding parameter of the background action class receives this parameter of the same name is a variable and not written as an array, it may also be a problem of the path...


I got this error. After careful inspection, I found that the name attribute of an input of the form was inconsistent with the corresponding attribute in the action, which was caused by the capitalization problem.

Example 2:

I am wrong about the problem of validate, the validation failed, so the action automatically returns "input", and then I don't define the page of <result name="input"></result>, so I report 404


When I encountered this problem, it was also a problem with the type of some value values ​​in the input tag of the jsp page.


<input id="pmbfkssj" name="led.ledBofangkaishishijian" type="time" value="08:00" class="form-control">
<input id="pmbfjssj" name="led.ledBofangjieshushijian" type="time" value="22:00" class="form-control">

In the above code, if you change 08:00 and 22:00 to 08:00:00 and 22:00:00 respectively, you can refer to: http://www.runoob.com/jsref/dom-obj-input- Example in time.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326940884&siteId=291194637