运行应用程序时struts异常

时间:2017-11-28 09:44:36

标签: java struts2

运行应用程序时,会显示类似这样的内容。

警告:StandardWrapperValve [jsp]:servlet jsp的Servlet.service()抛出异常     找不到Struts调度程序。这通常是由于使用没有关联过滤器的Struts标记引起的。 Struts标记仅在请求通过其servlet过滤器时可用,该过滤器初始化此标记所需的Struts调度程序。 - [未知位置]

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <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>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

add.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h3>Create/Edit</h3>
        <s:form action="#{studentController.add()}">
            <s:textfield id="id"  placeholder="Student Id" value="#{studentController.s.studentId}" required="true" requiredLabel="This field is manditory"></s:textfield><br>
            <s:textfield id="fname"  placeholder="First Name" value="#{studentController.s.firstName}" required="true" requiredLabel="This field is manditory"></s:textfield><br>
            <s:textfield id="lname"  placeholder="Last Name" value="#{studentController.s.lastName}" required="true" requiredLabel="This field is manditory"></s:textfield><br>
            <s:submit name="save" value="Save"></s:submit>

        </s:form>
    </body>
</html>

0 个答案:

没有答案