struts建立工程helloworld
Posted xiaobo-linux
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了struts建立工程helloworld相关的知识,希望对你有一定的参考价值。
WEB-INF:文件夹下web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>helloworld</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 配置核心拦截器-->
<filter>
<!-- Filter的名字-->
<filter-name>struts2</filter-name>
<!-- Filter的实现类struts2.5以前可能有所不同-->
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<!--拦截所有的url -->
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
WebContent文件夹下:
inputMessage.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>input message page</title>
</head>
<body>
<form action="helloworld.action" method="post">
Message:<input name="message" type="text">
<input type="submit"value="提交">
</form>
</body>
</html>
nomessage.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>noMessage</title>
</head>
<body>
no message was input!
</body>
</html>
showmessage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>show message page</title>
</head>
<body>
the input message is: <s:property value="message" />
</body>
</html>
运行结果:
!-- @import>!-- @import>
以上是关于struts建立工程helloworld的主要内容,如果未能解决你的问题,请参考以下文章
Myeclipse下的struts2.3.8 配置 保证绝对好用
SSH Struts2+hiberante+Spring整合