在Jsp页面里面将Struts标签所取的值赋给一个字符串
2013-05-22 22:40
375 查看
请注意19行到25行
参考:http://www.techienjoy.com/Struts2-example-steps-Tag-usage.php
源代码:http://pan.baidu.com/share/link?shareid=465109&uk=3878681452
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib uri="/struts-tags" prefix="struts2"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>西安Java培训西安小升初</title> </head> <body> <h2>预览页面</h2> <font color="green"> <b>名字:<struts2:property value="userName" /></b><br> <b>Roll No. : <struts2:property value="roll" /></b><br> <b>Section : <struts2:property value="section" /></b><br> <b>Std/Class : <struts2:property value="stdClass" /></b><br> </font> <p> <% String test; test = (String) request.getAttribute("userName"); //不是说用了struts就不需要java代码了 //这样做增加了灵活性,比如治理中文乱码,可以细化到字节级别 out.println(test); %> </p> </body> </html>
package sample; public class MyExample { private String userName; private String roll; private String section; private String stdClass; public String preview() throws Exception { return "preview"; } public String getUserName() { return this.userName; } public void setUserName(String argUserName) { userName = argUserName; } public String getRoll() { return this.roll; } public void setRoll(String argRoll) { roll = argRoll; } public String getSection() { return this.section; } public void setSection(String argSection) { section = argSection; } public String getStdClass() { return this.stdClass; } public void setStdClass(String argStdClass) { stdClass = argStdClass; } }
<struts2:form method="post" action="myexample" namespace="/sample"> <table> <tr> <td><struts2:textfield name="userName" label="姓名 " /></td> </tr> <tr> <struts2:textfield name="roll" label="Roll " /> </td> </tr> <tr> <td><struts2:textfield name="section" label="Section " /></td> </tr> <tr> <struts2:textfield name="stdClass" label="Std/Class " /> </td> </tr> <tr> <td colspan="2"><struts2:submit value="注册" /></td> </tr> </table> </struts2:form>
参考:http://www.techienjoy.com/Struts2-example-steps-Tag-usage.php
源代码:http://pan.baidu.com/share/link?shareid=465109&uk=3878681452
相关文章推荐
- 在Action中查询出SQL SERVER表的数据,返回一个list。怎么在JSP页面中使用Struts标签,显示出表中的内容?(转)
- springmvc中自定义日期转换器及其jsp页面日期显示的一个常用标签
- JSP页面遍历对象集合,map,数组等,Struts的s标签和c标签的区别
- struts2返回到JSP页面的html字符串如何在JSP页面上解析成html标签
- 在JSP页面中使用标签判断字符串长度的问题
- javaweb国际化,用struts标签解决,注意每个页面都是action跳jsp,并且拦截器的配置使得每次将国际化配置保存在session
- JSP页面JSTL提供的函数标签EL表达式操作字符串的方法
- struts2 标签截取字符串 struts2-在jsp页面中控制只显示前n个字符
- Struts2框架里面action与前端jsp页面进行交互路径问题---》一个对话框里面有很多超链接,进行相应的跳转
- struts项目中jsp页面调试方法---debug标签
- struts2:JSON在struts中的应用(JSP页面中将对象转换为JSON字符串提交、JSP页面中获取后台Response返回的JSON对象)
- jsp页面现在td标签显示长度 与 设置普通字符串显示字体长度
- 利用Struts标签开发jsp页面表单提示java.lang.NullPointerException: Module 'null' not found.
- 关于Jsp页面在ww:iterator 标签里面判断的写法是可以直接写数组里面的变量的
- jsp页面中对时间戳字符串格式化为时间标签
- jsp页面动态加载form标签的action地址和里面的submit按钮事件
- jsp页面中如何将时间戳字符串格式化为时间标签
- 关于jsp页面form标签里面的checkbox点击事件无效的原因之一
- 正确显示引入和使用Struts标签库的JSP页面
- jquery与后台进行数据交互--前台发单一数据对象,后台返回一个json字符串 jsp页面