- 创建web工程
2.添加strutslib库jar文件
3.创建struts配置文件struts-config.xml
4.在web.xml中配置struts-config配置文件及配置actionservlet
'''
action
org.apache.struts.action.ActionServlet
config
/WEB-INF/struts-config.xml
2
''
5.配置struts-config文件在配置文件中同时声明forward跳转页面配置及form关联配置
'''
'''
实例代码如下:
1 前台代码
登录页面
'''
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
My JSP 'index.jsp' starting page
This is my JSP page.
'''
成功页面
'''
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
My JSP 'ok.jsp' starting page
登录成功!!
'''
失败页面
'''
登录失败!!