使用struts2 標籤警告



初學struts2,用到Struts2標籤時 遇到如下警告

</pre>警告: No configuration found for the specified action: 'test1' in namespace: ''. Form action defaulting to 'action' attribute's literal value.2016-10-26 17:45:42 org.apache.struts2.components.ServletUrlRenderer warn警告: No configuration found for the specified action: 'test1' in namespace: ''. Form action defaulting to 'action' attribute's literal value.<p></p><p></p><p>Struts.xml文件</p><p></p><pre name="code" class="java"><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <package name="default" namespace="/" extends="struts-default">
    	<action name="test1" class="action.TestAction1">
    		<result name="success">/success.jsp</result>
    	</action>
    </package>
</struts>

index.jsp文件

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <body>
    <s:form action="test1" method="post">
    	name:<s:textfield name="user.name"></s:textfield>
    	password:<s:textfield name="user.password"></s:textfield>
    	<s:submit value="login"></s:submit>
    </s:form>
  </body>
</html>


在網上查了一下 解決方案是 在<s:form>標籤裏添加 namespace="/"  要和配置文件裏的namespace一致纔不會有這種警告

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章