Spring 静态页面例子


当前第2页 返回上一页

下面是 Spring 视图文件 WEB-INF/jsp/index.jsp 的内容。这将是一个登陆页面,这个页面将发送一个请求来访问 staticPage 的 service 方法,它将重定向这个请求到 WEB-INF/pages 文件夹中的一个可用的静态页面。

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
    <title>Spring Landing Page</title>
</head>
<body>
<h2>Spring Landing Pag</h2>
<p>Click below button to get a simple HTML page</p>
<form:form method="GET" action="/HelloWeb/staticPage">
<table>
    <tr>
    <td>
    <input type="submit" value="Get HTML Page"/>
    </td>
    </tr>
</table>  
</form:form>
</body>
</html>

下面是 Spring 视图文件 WEB-INF/pages/final.htm 的内容。

<html>
<head>
    <title>Spring Static Page</title>
</head>
<body>

<h2>A simple HTML page</h2>

</body>
</html>

最后,下面是包含在你的 web 应用程序中的 Spring 和其他库的列表。你仅仅需要将这些文件拖拽到 WebContent/WEB-INF/lib 文件夹中。

  • commons-logging-x.y.z.jar

  • org.springframework.asm-x.y.z.jar

  • org.springframework.beans-x.y.z.jar

  • org.springframework.context-x.y.z.jar

  • org.springframework.core-x.y.z.jar

  • org.springframework.expression-x.y.z.jar

  • org.springframework.web.servlet-x.y.z.jar

  • org.springframework.web-x.y.z.jar

  • spring-web.jar

一旦你完成了创建源代码和配置文件后,导出你的应用程序。右键单击你的应用程序,并且使用 Export > WAR File 选项,并且在 Tomcat 的 webapps 文件夹中保存你的 HelloWeb.war 文件。

现在启动你的 Tomcat 服务器,并且确保你能够使用标准的浏览器访问 webapps 文件夹中的其他 web 页面。现在尝试访问该 URL http://localhost:8080/HelloWeb/index。 如果你的 Spring Web 应用程序一切都正常,你应该看到下面的结果:

单击 “Get HTML Page” 按钮来访问 staticPage 中的 service 方法中提到的一个静态页面。如果你的 Spring Web 应用程序一切都正常,你应该看到下面的结果:



标签:Spring IoC

返回前面的内容

相关阅读 >>

spring 中基于 aop 的 @aspectj

spring 注入内部 beans

spring @autowired 注释

spring bean 生命周期

spring jsr-250 注释

spring 中 sql 的存储过程

spring bean 后置处理器

spring mvc hello world 例子

spring @required 注释

spring 自动装配 byname

更多相关阅读请进入《Spring IoC》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...