struts请求基本类型参数接收
01:导包,web.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <!-- 01:启动struts2框架 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
02:编写action类
package com.self.action;
/**
* 02:写相应的处理方法
*/
public class HelloWorldAction { private String user;
private Integer id; //处理方法
public String helloworld(){
return "rehelloworld";
} public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
} public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} }
03:配置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>
<!-- 01:将.action访问,改为.do和.action -->
<constant name="struts.action.extension" value="do,action" />
<!-- 02:指定默认编码,相当于HttpServletRequest的setCharacterEncoding方法,也作用于freemarker、velocity的输出 -->
<constant name="struts.i18n.encoding" value="UTF-8" /> <include file="department.xml"/>
</struts>
04:配置department.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="dep" namespace="/department" extends="struts-default">
<!-- 用通配符*来指代方法名,{1}代表第一个通配符所代表的字段:这里代表方法 -->
<action name="hd_*" class="com.self.action.HelloWorldAction" method="{1}" >
<result name="rehelloworld">
/successhelloworld.jsp
</result>
</action>
</package>
</struts>
05:编写输入数据界面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head> <title>显示</title>
</head> <!-- 第4步:显示 -->
<body>
<BR>
<BR>
<center>
<form action="department/hd_helloworld.do" method="post">
名:<input name="user" type="text">
<BR>
ID:<input name="id" type="text">
<BR>
<input type="submit" value="提交">
</form>
</center>
</body>
</html>
06:编写显示数据界面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head> <title>显示</title>
</head> <!-- 第4步:显示 -->
<body>
<BR>
<BR>
<center>
user=${user}
<BR>
id=${id}
</center>
</body>
</html>
08:访问路径
http://localhost:8080/Struts2_01/seehelloworld.jsp
struts请求基本类型参数接收的更多相关文章
- Jquery Datatables 请求参数及接收参数处理
Jquery Datatables 请求参数及接收参数处理 /** * Created by wb-wuyifu on 2016/8/9. */ /** * Created by wb-wuyifu ...
- vue axios 发送post请求,后端接收参数为null
1首先检查自己的传参方式是否正确,我是传一个对象,没有问题,接口也触发了 2查了下资料说是 Content-Type的问题,设置为 'application/x-www-form-urlencod ...
- java中两种发起POST请求,并接收返回的响应内容的方式 (转)
http://xyz168000.blog.163.com/blog/static/21032308201162293625569/ 2.利用java自带的java.net.*包下提供的工具类 代码如 ...
- SpringMvc 请求中日期类型参数接收一二事儿
首先说明:以版本为Spring 4.3.0为测试对象: 开启<mvc:annotation-driven /> 测试场景一:请求中含有date属性,该类型为日期类型,SpringMvc采用 ...
- Struts框架(6)---action接收请求参数
action接收请求参数 在web开发中,去接收请求参数来获得表单信息非常的常见,自己也总结整理了有关Struts2通过action接收请求参数的几种方法. Struts2 提供三种数据封装的方式: ...
- AngularJs的$http发送POST请求,php无法接收Post的数据解决方案
最近在使用AngularJs+Php开发中遇到php后台无法接收到来自AngularJs的数据,在网上也有许多解决方法,却都点到即止.多番摸索后记录下解决方法:tips:当前使用的AngularJ ...
- struts请求源码的跟踪
最近工作任务不是很紧,时间也不能白白浪费,以前常用的struts2框架源码没去了解过,所以就跟踪一下struts2的整个执行过程.由于本人也是抱着学习的态度来阅读掩码,若文章在表述和代码方面如有不妥之 ...
- PHP发送请求头和接收打印请求头
一.发送请求头 //发送地址 $url = 'http://127.0.0.1/2.php'; //请求头内容 $headers = array( 'Authorization: '.$basic, ...
- angular的post请求,SpringMVC后台接收不到参数值的解决方案
这是我后台SpringMVC控制器接收isform参数的方法,只是简单的打出它的值: @RequestMapping(method = RequestMethod.POST) @ResponseBod ...
随机推荐
- Bootstrap 进度条媒体对象和 Well 组件
一.Well 组件 这个组件可以实现简单的嵌入效果. //嵌入效果 <div class="well"> Bootstrap </div> //有 lg 和 ...
- style="display"之后不能获取offsetHeight或clientWidth这类测量的值
如果在html元素中设置了style="display:none;height:90px;"的属性后,是无法获得offsetLeft ,offsetWidth,offsetTop, ...
- SQL Server中的Image数据类型的操作
原文:SQL Server中的Image数据类型的操作 准备工作,在库Im_Test中建立一张表Im_Info,此表中有两个字段,分别为Pr_Id (INT),Pr_Info (IMAGE),用来存储 ...
- Java实验三报告
一. 实验内容 (一)敏捷开发与XP 摘要:一项实践在XP环境中成功使用的依据通过XP的法则呈现,包括:快速反馈.假设简单性.递增更改.提倡更改.优质工作.XP软件开发的基石是XP的活动,包括:编码 ...
- asp.net操作xml
下面是xml文档内容: <content width="368" height="450" bgcolor="cccccc" load ...
- qt QMessageBox QInputDialog
最近用到了QMessgaeBox和QInputDialog,QMessageBox用于提示,警告等消息,QInputDialog给用户弹出输入对话框. 参考链接 http://chenboqiang. ...
- web系统权限设计
应该有七张表 1.appSystem 表: 主要在多系统中的 统一权限管理:主要就是系统的URL USE [Star_Permission] GO /****** 对象: Table [dbo].[A ...
- http://localhost/certsrv 错误找不到页面解决方法
http://localhost/certsrv 错误找不到页面解决方法 最近公司需要后台启动安全证书,可安装了“Active Directory证书服务” 后,http://localhost/ce ...
- Java Final, Finally, Finalize
Final is a Keyword, final can be used in three different ways: final variable final method final cla ...
- SendEmail语法
SendEmail语法 示例: /usr/local/bin/sendEmail -f shengwei.tang@joy4you.com -t @qq.com -s smtp.exmail.qq.c ...