重学三大框架-Struts2
来源:互联网 发布:阿里云免费域名注册 编辑:程序博客网 时间:2024/05/16 11:26
好久没有用框架了,学的东西不用就会忘掉,今天开始重学三大框架
struts2介绍我就不多说了,想必你们应该比我还熟悉,现在我就讲下配置之类的问题
1.新建web项目
2.首先你要导入相关的包;因为新浪的bug问题我就发不了,你们也可以右击项目文件 点击myeclipse-Add Struts Capabilities选择Struts2.1
3.你的web.xml配置文件加上
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
4.新建一个reg.jsp页面写一个form表单提交 请求到action
<form action="user" method="post">
姓名:<input type="text" name="name"/><br>
密码:<input type="password" name="password"/>
<input type="submit" value="提交"/>
</form>
5.新建一个UserAction类继承ActionSupport实现execute方法
@Override
public String execute() throws Exception {
return SUCCESS;
}
6.新建一个struts.xml文件,里面这么写
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="user" extends="struts-default">
<action name="user" class="com.qm.UserAction">
<result name="index">/index.jsp</result>
</action>
</package>
</struts>
这里的action就是你reg.jsp页面提交到的Action class为处理的类
result为返回到哪!现在是返回到index.jsp页面
7.修改UserAction类
String name;
String password;
@Override
public String execute() throws Exception {
//System.out.println("测试成功");
System.out.println("用户名:"+name);
System.out.println("密码:"+password);
//index是struts.xml返回的名字
return "index";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
struts2介绍我就不多说了,想必你们应该比我还熟悉,现在我就讲下配置之类的问题
1.新建web项目
2.首先你要导入相关的包;因为新浪的bug问题我就发不了,你们也可以右击项目文件 点击myeclipse-Add Struts Capabilities选择Struts2.1
3.你的web.xml配置文件加上
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
4.新建一个reg.jsp页面写一个form表单提交 请求到action
<form action="user" method="post">
姓名:<input type="text" name="name"/><br>
密码:<input type="password" name="password"/>
<input type="submit" value="提交"/>
</form>
5.新建一个UserAction类继承ActionSupport实现execute方法
@Override
public String execute() throws Exception {
return SUCCESS;
}
6.新建一个struts.xml文件,里面这么写
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="user" extends="struts-default">
<action name="user" class="com.qm.UserAction">
<result name="index">/index.jsp</result>
</action>
</package>
</struts>
这里的action就是你reg.jsp页面提交到的Action class为处理的类
result为返回到哪!现在是返回到index.jsp页面
7.修改UserAction类
String name;
String password;
@Override
public String execute() throws Exception {
//System.out.println("测试成功");
System.out.println("用户名:"+name);
System.out.println("密码:"+password);
//index是struts.xml返回的名字
return "index";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
现在工作就完成了。打开浏览器输入地址访问!
我的新浪博客和csdn一起发的!这是我的博客文章地址:http://blog.sina.com.cn/s/blog_b34a581f0102w16n.html!大神们请轻虐
2 0
- 重学三大框架-Struts2
- Struts2 框架
- struts2框架
- Struts2 框架
- Struts2框架
- Struts2框架
- Struts2框架
- Struts2框架
- struts2框架
- struts2框架
- Struts2框架
- 框架:Struts2
- struts2框架
- Struts2框架
- 【Struts2框架】Struts2总结
- WEB Struts2 构建struts2框架
- Struts2(0):Struts2框架入门
- struts2学习----模拟struts2框架
- asp输出变量
- 设计模式
- grep -r常用样例
- 在 Linux 中怎样将 MySQL 迁移到 MariaDB 上
- Activity启动模式
- 重学三大框架-Struts2
- IOS相机使用学习笔记
- 关于引用本地资源图片 造成OOM的解决方案
- node.js全局变量console总结
- js手机界面调用安卓app
- MySQL
- Android仿搜狗浏览器加载动画
- 记录下Oracle 查询节点
- 《Linux Shell》笔记之dos2unix