在struts2和jsp上的小程序 [英] small program on struts2 and jsp

查看:51
本文介绍了在struts2和jsp上的小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经基于一个项目对struts进行了一些学习.现在我必须构建2到3个struts jsp页面.

i have done some learning on struts based on one project that i got.Now i have to build 2 to 3 struts jsp pages.

我有以下情况.

<action name="BackAction" class="ClassnamePath">
<result name="user_validated" type="redirectAction">
                <param name="actionName">welcome</param>
            </result>
<result name="user_profile_found_in_database">/resources/userprofile.jsp</result>

param会告诉什么..param的意义是什么(我对此一无所知)

what does param will tell..what is the significance of param(i do not know about this)

我的情况是这样的在类(ClassnamePath)中,我完成了一个Java程序,该程序从数据库中获取数据并将值放在userprofile.java中(例如,用户配置文件具有诸如name,email,phone之类的变量成员. ,别针) 这些值来自数据库,并存储在userprofile类的对象中.

my scenario is like this In the class(ClassnamePath) i have done one java program which bring the data from the database and put the values in the userprofile.java(for example the userprofile has variable members like name,email,phone,pin) that values are come from database and stored in the object of the class userprofile.

我的任务是,每当完成"user_profile_found_in_database"结果后,这些值就应作为"user_profile_found_in_database""的结果显示在jsp中.

i have a task that whenever the result "user_profile_found_in_database" has been done those values should be presented in the jsp as result of the "user_profile_found_in_database"

我在操作标记中提到的结果"user_profile_found_in_database"正确吗?

Is the result "user_profile_found_in_database" that i mentioned in the action tag correct?

jsp页面应该具有带有标签的用户简要表,因为用户简要表的字段和值应该在文本框中.

the jsp page should be having userprofile with labels as the fields of the userprofile and values should be in the text boxes.

我对jsp页面一无所知...即使是Web编程..但我还是自己学习..(我怀疑jsp页面与struts jsp页面有何不同) 通过上述任务,我可以在struts和jsp中学到很多东西.

i do not know anything about jsp pages...even web programming..but i am learning on my own..(i am having one doubt how jsp pages are different from struts jsp pages) with the above tasks i can learn lot in struts and jsp..

请提供一些知识以进一步构建.

Please give some knowledge on this to build further.

推荐答案

JSP页面与简单的JSP页面没有什么不同,简而言之,Struts2将提供一组标签,这些标签将帮助我们作为最终开发人员快速构建应用程序,这些标签提供了有关S2提供的各种功能的易于访问的功能,

JSP pages are not way different than simple JSP pages and in short Struts2 will provides a set of tags which will help we as an end developer to build application fast as these tags provides a easy to access functionality about various features S2 providing, few of them are

  1. 使用OGNL访问价值栈
  2. 从服务器到客户端的数据转换以及其他方式
  3. 具有以最简单,灵活的方式访问其他内容(如请求/响应/会话)的功能.

最后,当浏览器呈现jsp页面时,将是简单的HTML和在其中应用程序中使用的S2标签,因为浏览器将理解HTML,因此它将转换为HTML.

In end when you browser will render the jsp page it will be simple HTML and S2 tags one using in there application will be converted to the HTML as browser will understand HTML.

关于在jsp中访问用户个人资料的第二部分,请执行以下杜松子酒操作类

regarding second part accessing user profile in your jsp do the following gin your Action class

  1. 在您的操作类中创建UserProfile的实例
  2. 为UserProfile实例创建getter和setter
  3. 填写用户个人资料中的值(您将从数据库调用中获取该值)

当您的操作将响应发送回去时,S2会将用户配置文件实例放置在Value堆栈的顶部,我们可以使用S2标签(例如,

when your action will send back the response, S2 will place the user-profile instance on top of Value stack and we can access its properties using S2 tags like

<s:textfield name="user_name" value="%{name}"/>
<s:textfield name="user_age" value="%{age}"/>

此处nameage是用户配置文件的属性.redirectAction配置中的param用于为结果提供参数,有关哪些参数的更多信息,请阅读官方文档

here name and age are the properties of your user-profile.param in your redirectAction configuration is being used to provide parameters to the result, for more information about what parameters do please read official document.

.

这篇关于在struts2和jsp上的小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆