我快疯了。我从几个小时开始就在寻找我的错误。
我的表格不会生效。但是我检查了1000次。一切都拼写正确。我不知道...请帮忙!
我心爱的错误信息:
HTTP 状态 404 - 未为操作 de.nordakademie.librarymgmt.action.CreatePubAction 和结果输入定义结果
类型状态报告
消息没有为动作 de.nordakademie.librarymgmt.action.CreatePubAction 和结果输入定义结果
描述 请求的资源不可用。
Apache Tomcat/7.0.42
这就是jsp。在名为 createPublication.jsp 的文件夹 jsp 中
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!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=ISO-8859-1">
<title></title>
</head>
<body>
<h3>Fügen Sie eine neue Publikation hinzu</h3>
<s:form action="createPubAction">
<s:textfield key="publication.title" />
<%-- <s:textfield key="publication.author" /> --%>
<s:textfield key="publication.publisher" />
<s:textfield key="publication.publishment" />
<s:textfield key="publication.isbn" />
<s:textfield key="publication.stock" />
<s:if test="%{publicationtypes.isEmpty()}">
keine Publikationstypen
</s:if>
<s:else>
<s:select Listkey="publication.type" list="publicationtypes.{type}" />
</s:else>
<s:if test="%{keywords.isEmpty()}">
keine Schlagwörter
</s:if>
<s:else>
<s:checkboxlist key="publication.keyword" label="Schlagworte"
name="keywordsL1" list="keywords.{name}" />
</s:else>
<s:submit label="save" value="Speichern" />
</s:form>
</body>
</html>
Struts.xml newPublication 正在调用我需要输入所需信息的页面
<?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">
<!-- mapping of global-results and global-exceptions -->
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<default-action-ref name="Start" />
<action name="Start" class="de.nordakademie.librarymgmt.action.StartAction">
<result type="tiles" name="success">main</result>
</action>
<action name="newPublication"
class="de.nordakademie.librarymgmt.action.NewPublication">
<result type="tiles" name="success">createPublication</result>
</action>
<action name="createPubAction"
class="de.nordakademie.librarymgmt.action.CreatePubAction">
<result type="tiles" name="success">catalog</result>
</action>
<action name="catalogAction"
class="de.nordakademie.librarymgmt.action.navi.CatalogAction">
<result type="tiles" name="success">catalog</result>
</action>
</package>
</struts>
瓷砖文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="main" template="/jsp/main.jsp">
<put-attribute name="title" value="Dashboard"/>
<put-attribute name="menu" value="/jsp/menu.jsp"/>
<put-attribute name="header" value="/jsp/header.jsp"/>
<put-attribute name="content" value="/jsp/start.jsp"/>
</definition>
<definition name="dashboard" extends="main">
<put-attribute name="title" value="Dashboard"/>
<put-attribute name="content" value="/jsp/start.jsp"/>
</definition>
<definition name="rental" extends="main">
<put-attribute name="title" value="Verleihvorgänge"/>
<put-attribute name="content" value="/jsp/rental.jsp"/>
</definition>
<definition name="catalog" extends="main">
<put-attribute name="title" value="Katalog"/>
<put-attribute name="content" value="/jsp/catalog.jsp"/>
</definition>
<definition name="createPublication" extends="main">
<put-attribute name="title" value="Neue Publikation erstellen"/>
<put-attribute name="content" value="/jsp/createPublication.jsp"/>
</definition>
</tiles-definitions>
最后但并非最不重要的行动:
package de.nordakademie.librarymgmt.action;
import com.opensymphony.xwork2.ActionSupport;
import de.nordakademie.librarymgmt.model.Publication;
import de.nordakademie.librarymgmt.service.IPublicationService;
public class CreatePubAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private Publication publication;
private IPublicationService publicationService;
@Override
public String execute() throws Exception {
try{
publicationService.savePublication(publication);
return SUCCESS;
} catch(Exception e){
e.printStackTrace();
return ERROR;
}
}
public Publication getPublication() {
return publication;
}
public void setPublication(Publication publication) {
this.publication = publication;
}
public IPublicationService getPublicationService() {
return publicationService;
}
public void setPublicationService(IPublicationService publicationService) {
this.publicationService = publicationService;
}
}