html - Struts 2 example now working -
i new struts2. trying little application practice nail issue.
i trying forwards straight index.jsp login.jsp
. know can straight forwards login.jsp below code should valid. attaching code trying. below code trying.
index.jsp
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>home</title> </head> <body> <jsp:forward page="login.action" /> </body> </html>
struts.xml
<struts> <include file="example.xml"/> <!-- configuration default package. --> <package name="default" extends="struts-default"> <action name="login"> <result>/login.jsp</result> </action> </package>
login.jsp
<%@page contenttype="text/html" pageencoding="utf-8"%> <%@taglib prefix="s" uri="/struts-tags" %> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>jsp page</title> </head> <body> <s:form> <s:textfield name="user" label="user name" /> <s:password name="passwd" label="password" /> </s:form> </body>
in web.xml index.php page set welcome page. suppose xyz context name, when set /xyz/login
take login page when set /xyz/
in browser give , resource not found error.
when utilize <meta http-equiv="refresh" content="0;url=login.action">
1 time again works fine.
i using tomcat7 web server. can 1 tell why happening so.
not containers default perform forwards non-jsp resources - <jsp:forward/>
- container please add together next mapping web.xml:
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> <dispatcher>request</dispatcher> <dispatcher>forward</dispatcher> </filter-mapping>
html jsp struts2
No comments:
Post a Comment