The request action path in the form form in struts and the attention point of the response path in Struts-config.xml

Source: Internet
Author: User
Tags ssh

For example: I set up an SSH project demo, the project structure as shown in the following diagram:


This project has a login interface, there is a login.jsp file, this file form form request is as follows

<body>
    

This form can also be written in this form

<body>
    

Configure the response action path in Struts-config.xml as follows

<struts-config>
	<form-beans>
		<form-bean name= "Employeeform" type= " Com.gt.web.forms.EmployeeForm "></form-bean>
	</form-beans>
	<action-mappings>
		<action path= "/login" parameter= "flag" name= "Employeeform" type= "com.gt.web.action.LoginAction" >
			< Forward name= "OK" path= "/web-inf/mainframe.jsp" ></forward>
			<forward name= "error" path= "/web-inf/ login.jsp "></forward>
		</action>
	</action-mappings>
</struts-config>
Here we find that the first URL path can be used in the form, this is the absolute path of the writing, the second is a relative path, do not need to write a slash, the system by default is the project, in this project is/ssh ("SSH" for the project name) below.

There is also a third way of writing, which is to use Request.getcontextpath () to get the project root path

<body>
    


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.