package action;
import com.opensymphony.xwork2.ActionSupport;
import entity.User;
public class UserAction extends ActionSupport {
private User user = new User();
public String login() {
System.out.println(user.getUserName() + "\n" + user.getPassword());
return "success";
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
package action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import com.opensymphony.xwork2.ActionSupport;
import entity.User;
@Namespace("/user")
@Results(
{
@Result(name="success",location="/success.jsp"),
@Result(name="fail",location="/fail.jsp")
}
)
public class User2Action extends ActionSupport {
private User user = new User();
public String login() {
System.out.println(user.getUserName() + "\n" + user.getPassword());
return "success";
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="utf-8"></constant> <!-- 字符编码 -->
<!--<constant name="struts.devMode" value="true"></constant> 开发模式 -->
<!--<constant name="struts.action.extension" value="action"></constant> Action后缀 -->
<!--<include file=""></include> 配置文件 -->
<!--<bean class=""></bean> 配置Bean -->
<package name="user" namespace="/user" extends="struts-default">
<!--<interceptors> --><!-- 拦截器配置 -->
<!--<interceptor name="" class=""></interceptor> 配置拦截器 -->
<!--</interceptors>
--><!--<global-results> 全局resulst -->
<!--<result name=""></result> 配置result -->
<!--</global-results>
--><!--<global-exception-mappings> 全局异常 -->
<!--<exception-mapping result="" exception=""></exception-mapping> 配置异常 -->
<!--</global-exception-mappings>
--><action name="userAction" class="action.UserAction">
<result name="success">/success.jsp</result>
</action>
</package>
</struts>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="user/userAction!login" method="post">
<input type="text" name="user.userName" /><br/>
<input type="password" name="user.password"><br/>
<input type="submit" value="登录" />
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'success.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
${user.userName }登录成功...
</body>
</html>
分享到:
相关推荐
使用struts2写的一个小demo,方便易懂,有兴趣的可以下载下来看看,基本的jar包都有了,只需要动动小手就能用。
这是一个关于用户登录验证的界面项目,较为简单,仅供参考
5、作者对不同的struts2漏洞测试语句做了大量修改,执行命令、上传功能已经能通用。 6、支持HTTPS。 7、支持GET、POST、UPLOAD三种请求方法,您可以自由选择。(UPLOAD为Multi-Part方式提交) 8、部分漏洞测试支持...
轻量级Java_EE企业应用实战_Struts_2+Spring_3+Hibernate整合开发_第3版_mk.zip.001
参考博文:http://blog.csdn.net/u011638419/article/details/41241575
Struts2漏洞列表,S2-001 —— S2011,结合了kxlzx大牛的某些分析文档。自用。
【】兄弟连_马剑威_001_回顾MVC模式之查询Pet列表 【】兄弟连_马剑威_002_HelloStruts2入门 【】兄弟连_马剑威_003_Struts2_Action(1) 【】兄弟连_马剑威_003_Struts2_Actio 资源太大,传百度网盘了,...
Struts2应用开发详解]_001.Struts2.2概述与MVC模式深度剖析
01介绍struts2及struts2开发环境的搭建.zip.001 由于上传限制分2部分上传
Struts 2练习源码 第一天001Struts 2练习源码 第一天001Struts 2练习源码 第一天001Struts 2练习源码 第一天001Struts 2练习源码 第一天001Struts 2练习源码 第一天001Struts 2练习源码 第一天001Struts 2练习源码 ...
目前两种模式scan和exec支持:struts2-001struts2-005struts2-007struts2-008struts2-009struts2-012struts2-013struts2-015struts2-016struts2-045struts2-046struts2-048struts2-053struts2-057开发目的1、适用于...
[浪曦原创]Struts系列 第6讲 Struts的验证框架Validate使用续二(zk001)
Struts2-RCE 一个Burp Extender,用于检查struts 2 RCE漏洞。描述此burp扩展有助于识别struts2 Web应用程序中的Struts2远程代码执行漏洞。 此Burp扩展程序检测以下18个RCE,它们是S2-001 S2-007 S2-008 S2-012 S2-...
Struts2-ScanStruts2漏洞利用扫描工具,基于互联网上已经公开的Structs2高危漏洞exp的扫描利用工具,目前支持的漏洞如下: S2-001, S2-003, S2-005, S2-007, S2-008, S2-009, S2-012, S2-013, S2-015, S2-016, S2-019...
Struts2的一个关键特性就是它可以对Action携带的数据进行读写访问,例如在前面我们在表单中使用user.username指定数据传递给Action的user对象的username属性,在元素中使用user.username来获取用户的名字,这是通过...
[浪曦原创]Struts系列 第2讲 Struts介绍续一(zk001)
2、用户名只能使用数字或者字母,长度为6~20之间...5、收入必须在0.001~10000.000之间; 6、年龄必须是整数且必须在0~120之间; 7、出生日期必须是正确的日期格式,如2009-10-11,且只能在1900-1-1至2011-4-1之间;
本资源主要使用struts2实现实现后台服务,demo很简单,只含有struts2的代码,另两个框架,对于学过写ssh的很容易就能拼凑进去。url的拼凑:localhost:8080/MobileBackService/Login?jsonDate={"date": {"loginName":...
官方通告:https://cwiki.apache.org/confluence/display/WW/S2-007漏洞环境或者在Struts2-001 dem
第一步 断点在 package com.opensymphony.xwork2.util 第二步 这里去调用 package com.opensymphony.