[英]Struts form not working with struts tiles
我正在设计一个购物车项目,其中我的内容区域仅会发生变化,因此我使用struts tile对其进行了配置,并且一切正常,直到在项目中遇到表单为止。 每当我尝试使用图块显示表单(struts表单)时。 表单尚未编译,只是因为<html:text property="username"/>
请帮忙。
我的图块定义为
<tiles-definitions>
<definition name="main-layout" path="/WEB-INF/layout.jsp">
<put name="title" value="" />
<put name="header" value="/WEB-INF/layout/header.jsp"/>
<put name="secmenu" value="/WEB-INF/layout/secmenu.jsp"/>
<put name="menu" value="/WEB-INF/layout/menu.jsp"/>
<put name="content" value=""/>
<put name="footer" value="/WEB-INF/layout/footer.jsp"/>
</definition>
<definition name="index" extends="main-layout">
<put name="title" value="The Mobile Store"/>
<put name="content" value="/WEB-INF/pages/homecontent.jsp"/>
</definition>
<definition name="login" extends="main-layout">
<put name="title" value=":: Login ::"/>
<put name="content" value="/WEB-INF/pages/login.jsp"/>
</definition>
我使用的表格是
<html:form action="login.html" method="post">
<table align="center" id="logintable">
<tr>
<td>Enter Your UserName : </td>
<td><html:text property="username"/></td>
</tr>
<tr>
<td>Enter Your Password : </td>
<td><html:password property="password"/></td>
</tr>
<tr>
<td colspan="2"><html:submit value="LOGIN"/></td>
</tr>
</table>
</html:form>
我认为您遇到了问题,因为您尝试访问WEB-INF文件夹中的jsp文件。 如果您尝试使用struts 1.x,请尝试使用struts 2.0。 对于本教程,请使用此http://viralpatel.net/blogs/struts-2-tiles-plugin-tutorial-with-example-in-eclipse/
您必须将tile插件包含在struts-config
; 请点击以下链接获取更多信息:
http://www.mkyong.com/struts/struts-tiles-framework-example/
查看您的struts配置文件。 在action标签的action-mapping中,必须指定formName。 看起来像这样
<action-mappings>
<action path="/Action" name="form">
在这之后,您必须在jsp页面中添加taglib <%@taglib uri="struts.apache.org/tags-html"; prefix="html"%>
<%@taglib uri="struts.apache.org/tags-html"; prefix="html"%>
您可以使用html标签,如下所示:
在您的struts-config中输入以下内容:
<message-resources parameter="properties.labels" />
在我的应用标签属性中位于:
并在您的jsp中:
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
并使用如下所示的bean标签:
<bean:message key="password" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.