分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

创建一个视图JSP文件的helloWorld.jsp

发布时间:2023-09-06 02:10责任编辑:苏小强关键词:jsjsp

让我们创建下面的JSP文件的helloWorld.jsp,在WebContent文件夹在你的eclipse项目。要做到这一点,右键单击WebContent文件夹中的项目资源管理器,然后选择“新建”>“JSP文件。该文件将被要求的情况下,返回的结果是success,这是一个字符串常量“成功”的定义在Action接口:

<%@ page contentType="text/html; charset=UTF-8" %><%@ taglib prefix="s" uri="/struts-tags" %><html><head><title>Hello World</title></head><body> ??Hello World, <s:property value="name"/></body></html>

以下是文件,该文件将被调用的框架的情况下作用的结果是等于字符串常量“ERROR”的错误,这是。以下内容的AccessDenied.jsp的

<%@ page contentType="text/html; charset=UTF-8" %><%@ taglib prefix="s" uri="/struts-tags" %><html><head><title>Access Denied</title></head><body> ??You are not authorized to view this page.</body></html>

我们还需要在WebContent文件夹中创建的index.jsp。该文件将作为初始动作URL,用户可以直接点击告诉Struts 2框架,以调用execute方法HelloWorldAction类,并呈现HelloWorld.jsp视图。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" ??pageEncoding="ISO-8859-1"%><%@ taglib prefix="s" uri="/struts-tags"%> ??<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Hello World</title></head><body> ??<h1>Hello World From Struts2</h1> ??<form action="hello"> ?????<label for="name">Please enter your name</label><br/> ?????<input type="text" name="name"/> ?????<input type="submit" value="Say Hello"/> ??</form></body></html>

就是这样,有没有需要改变的web.xml文件,让我们使用同一个web.xml举例章节,我们已经创建了。现在,我们已经准备好来运行我们的Hello World应用程序使用Struts 2框架。

创建一个视图JSP文件的helloWorld.jsp

原文地址:https://www.cnblogs.com/borter/p/9502141.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved