- 爱易网页
-
Java教程
- 使用struts2标签需要配置嘛?为什么小弟我的页面上的标签不起作用呢
日期:2014-05-18 浏览次数:20839 次
使用struts2标签需要配置嘛?为什么我的页面上的标签不起作用呢?
我初学struts2,在自己新建一个工程中有如下页面:
==========================================
login.jsp
<%@ taglib prefix= "s " uri= "/struts-tags " %>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=UTF-8 ">
<title> Showcase - Conversion - Populate Object into Struts ' action List </title>
</head>
<body>
<s:form>
<s:textfield label= "userName: " name= "userName " />
<s:textfield label= "password: " name= "password " />
<s:submit name= "ccc " value= "bbb "/>
</s:form>
</body>
</html>
----------------------------------
web.xml
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app id= "WebApp_ID " version= "2.4 "
xmlns= "http://java.sun.com/xml/ns/j2ee "
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<display-name> mySample </display-name>
<filter>
<filter-name> struts2 </filter-name>
<filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name> struts2 </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file> index.html </welcome-file>
<welcome-file> index.htm </welcome-file>
<welcome-file> index.jsp </welcome-file>
<welcome-file> default.html </welcome-file>
<welcome-file> default.htm </welcome-file>
<welcome-file> default.jsp </welcome-file>
</welcome-file-list>
</web-app>
----------------------------------
struts.xml
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN "
"http://struts.apache.org/dtds/struts-2.0.dtd ">
<struts>
<package name= "default " extends= "struts-default ">
<action name= "login " class= "com.xiangzi.LoginAction ">
<result name= "input "> /login.jsp </result>
<result> /welcome.jsp </result>
</action>
<action name= "append " class= "com.xiangzi.AppendIteratorTagAction ">
<result> appendIterator_sample.jsp </result>
</action>
</package>
</struts>
大概代码和配置如上,
我使用tomcat5.5+jdk1.5+ec3.2
当我启动服务器的时候并运行http://localhost/mySample/login.jsp
页面上竟然什么内容都没有.请高手指点
------解决方案--------------------
是不是标签引入错误,我也是个菜鸟