maven项目中struts添加

pom.xml中添加struts

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.3.16</version>
</dependency>

maven自动会添加其他相关的jar包

src/main/resources下添加struts.xml文件

和旧的版本一比较,struts.enable.DynamicMethodInvocation在2.3.15版本里设置的是true,而在2.3.16.3里是设置为false的。

<struts>
	<!-- 动态方法 -->
	<constant name="struts.enable.DynamicMethodInvocation" value="true" />
    <constant name="struts.devMode" value="true" />
    
    <package name="user" namespace="/"  extends="struts-default">
        <action name="loginManage" class="login.struts.LoginAction" >
            <result name="success">/welcome.jsp</result>
            <result name="retPsd">/retPsd.jsp</result>
        </action>
    </package>
</struts>

写一个Action类,继承ActionSupport,写两个方法,分别转向retPsd.jsp,welcome.jsp,测试转向成功

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

	public String login() {
		
		return "success";
	}
	
	public String retPsd() {
		return "retPsd";
	}
}

猜你喜欢

转载自blog.csdn.net/wenkou4945/article/details/86492683
今日推荐