Today I wrote a landing page. I believe this is not difficult for everyone, but as a silk girl, I made a mistake once!
The login page form is submitted. In the action, I added the namespace. The details are as follows:
<form id="loginForm" action="actionPackage/login.action" method="post"> ...此处省略...</form>
Login is fine. Problem, but the problem is that when my username or password is wrong, I should return to the login page. When I return, although the following method can be used to return to the specified html document
<package name="actionPackage" namespace="/actionPackage" extends="struts-default" > <action name="login" class="loginAction" method="execute"> <result name="success">/WEB-INF/index.html</result> <result name="error" >/login.html</result> </action> </package>
<script language="javascript" type="text/javascript" src="jquery-1.8.0.min.js" />
When logging in to submit the form, the actionPage namespace will be added to the URL. Then when returning to login.html, the URL will naturally include actionPage, causing the path to be obtained when getting the external js file. There is also an obvious space called actionPage in the file. Of course, this js external file cannot be obtained!
The url when logging in becomes http://localhost:8080/lfdcwtjxt/actionPage/login.action
When you return to the login page, the js acquisition path becomes http:/ /localhost:8080/lfdcwtjxt/actionPage/jquery-1.8.0,js
This is wrong, it should be http://localhost:8080/lfdcwtjxt/jquery-1.8.0,js
The solution is:
Use redirection to solve the problem: the configuration is as follows
<package name="actionPackage" namespace="/actionPackage" extends="struts-default" > <action name="login" class="loginAction" method="execute"> <result name="success">/WEB-INF/index.html</result> <result name="error" type="redirect">/login1</result> </action></package>
Redirect configuration:
<package name="default" namespace="/" extends="struts-default"> <action name="login1"> <result>/login.html</result> </action></package>
I don’t know if there is any other way, welcome to kick the floor!