{"id":1860,"date":"2011-03-30T12:29:00","date_gmt":"2011-03-30T06:59:00","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=1860"},"modified":"2011-03-30T12:29:00","modified_gmt":"2011-03-30T06:59:00","slug":"error-resolved-form-action-defaulting-to-action-attributes-literal-value","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/error-resolved-form-action-defaulting-to-action-attributes-literal-value\/","title":{"rendered":"Error Resolved- Form action defaulting to &#8216;action&#8217; attribute&#8217;s literal value"},"content":{"rendered":"<p>This Error normally comes while using <strong><a title=\"Dynamic Method Invocation\" href=\"https:\/\/jitendrazaa.com\/blog\/java\/struts\/explain-dynamic-method-invocation-in-struts-2\/\" target=\"_blank\">Dynamic Method invocation<\/a><\/strong> of Struts 2.<br \/>\nConsider below code:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;s:form &gt;\n&lt;s:textfield name=&quot;num1&quot; label=&quot;Number 1&quot;&gt;&lt;\/s:textfield&gt;\n&lt;s:textfield name=&quot;num2&quot; label=&quot;Number 2&quot;&gt;&lt;\/s:textfield&gt;\n&lt;s:submit action=&quot;calculator_add&quot; value=&quot;Add&quot; \/&gt;\n&lt;s:submit action=&quot;calculator_sub&quot; value=&quot;Substract&quot; \/&gt;\n&lt;\/s:form&gt;\n<\/pre>\n<p>In Above example, two action methods are called in a single form.<!--more--><\/p>\n<p>Let&#8217;s say configuration file contains below setting:<\/p>\n<pre class=\"brush: xml; highlight: [17,18,19,20]; title: ; notranslate\" title=\"\">\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;\n&lt;!DOCTYPE struts PUBLIC\n        &quot;-\/\/Apache Software Foundation\/\/DTD Struts Configuration 2.0\/\/EN&quot;\n        &quot;http:\/\/struts.apache.org\/dtds\/struts-2.0.dtd&quot;&gt;\n\n&lt;struts&gt;\n\n\t&lt;package name=&quot;calc&quot; extends=&quot;struts-default&quot;&gt;\n\t\t&lt;action name=&quot;calculatorInput&quot;&gt;\n\t\t\t&lt;result&gt;\/pages\/calculator.jsp&lt;\/result&gt;\n\t\t&lt;\/action&gt;\n\n\t\t&lt;action name=&quot;calculatorResult&quot;&gt;\n\t\t\t&lt;result&gt;\/pages\/calculatorResult.jsp&lt;\/result&gt;\n\t\t&lt;\/action&gt;\n\n\t\t&lt;action name=&quot;calculator_*&quot; method=&quot;{1}&quot;\n\t\t\tclass=&quot;com.G2.Actions.CalculatorAction&quot;&gt;\n\t\t\t&lt;result name=&quot;success&quot; type=&quot;chain&quot;&gt;calculatorResult&lt;\/result&gt;\n\t\t&lt;\/action&gt;\n\n\t&lt;\/package&gt;\n&lt;\/struts&gt;\n<\/pre>\n<p>If we try to access the page via action like &#8220;http:\/\/localhost:8080\/DynamicMethodInvocation\/calculatorInput.action&#8221;\u009d<br \/>\nThen the code runs fine.<\/p>\n<p>When we try to access the same page directly:<br \/>\n&#8220;http:\/\/localhost:8080\/DynamicMethodInvocation\/pages\/calculator.jsp&#8221;\u009d<br \/>\nBoom !!!  we got error <strong>&#8220;Form action defaulting to &#8216;action&#8217; attribute&#8217;s literal value&#8221;<\/strong>.<\/p>\n<p>If you observe the jsp code clearly, you can see that there is no action attribute is set in the tag &lt;s:form&gt;.<br \/>\nSo, to overcome this problem, <strong>we must specify the default action in &lt;s:form&gt;.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Error Resolved in Struts 2- Form action defaulting to &#8216;action&#8217; attribute&#8217;s literal value<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[16],"tags":[335],"class_list":["post-1860","post","type-post","status-publish","format-standard","hentry","category-struts","tag-struts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1851,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/dynamic-results-in-struts-2\/","url_meta":{"origin":1860,"position":0},"title":"Dynamic Results in Struts 2","author":"Jitendra","date":"March 30, 2011","format":false,"excerpt":"Example and sourcecode of creating Dynamic Results in Struts 2","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1834,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/step-by-step-simple-login-application-in-struts-2\/","url_meta":{"origin":1860,"position":1},"title":"Step by Step Simple Login Application in Struts 2","author":"Jitendra","date":"March 24, 2011","format":false,"excerpt":"Example of Simple Login Application in Struts 2","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"Final Structure of Struts 2 login application","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Final-Structure-of-Struts-2-login-application.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1864,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/explain-dynamic-method-invocation-in-struts-2\/","url_meta":{"origin":1860,"position":2},"title":"Explain dynamic method invocation in Struts 2","author":"Jitendra","date":"March 30, 2011","format":false,"excerpt":"Explain dynamic method invocation in Struts 2","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1829,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/struts\/what-is-struts-2-and-how-it-works\/","url_meta":{"origin":1860,"position":3},"title":"What is Struts 2 and how it works","author":"Jitendra","date":"March 24, 2011","format":false,"excerpt":"What is Struts 2 and how it works?","rel":"","context":"In &quot;Struts&quot;","block_context":{"text":"Struts","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/struts\/"},"img":{"alt_text":"How Struts 2 Works","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/How-Struts-2-Works.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2034,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/tutorial-of-simple-jsp-tiles-application-without-struts\/","url_meta":{"origin":1860,"position":4},"title":"Tutorial of Simple JSP Tiles application without Struts","author":"Jitendra","date":"April 15, 2011","format":false,"excerpt":"Example of Simple JSP Tiles application without Struts","rel":"","context":"In &quot;JSP&quot;","block_context":{"text":"JSP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/jsp\/"},"img":{"alt_text":"Simple JSP Tiles without Struts","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/04\/Simple-JSP-Tiles-without-Struts.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1029,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/logging-made-easy-in-net-log-4-net\/","url_meta":{"origin":1860,"position":5},"title":"Logging made easy in .NET &#8211; log 4 net","author":"Jitendra","date":"September 30, 2010","format":false,"excerpt":"How to use the log 4 net in .Net application. Example, demonstration and sourcecode","rel":"","context":"In &quot;c#&quot;","block_context":{"text":"c#","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/csharp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=1860"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1860\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=1860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=1860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=1860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}