2017-03-05 73 views
0

我的代码中有哪些类型的错误? This is my Project Screenshots 任何Jar文件问题或代码问题? 任何Jar文件问题或代码问题? 任何Jar文件问题或代码问题?没有为命名空间/和操作名称reg映射的操作。 - [未知位置]

的index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
     pageEncoding="ISO-8859-1"%> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <%@taglib uri="/struts-tags" prefix="s" %> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
    <title>Insert title here</title> 
    </head> 
    <body> 
     <s:form action="reg" method="post"> 
      <s:textfield name="firstname" label="FirstName"/> 
      <s:textfield name="lastname" label="LastName"/> 
      <s:submit value="submit"/> 
     </s:form> 
    </body> 
    </html> 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> 
    <display-name>StrutsAnnotation</display-name> 
    <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> 
    <filter> 
     <filter-name>struts2</filter-name> 
     <filter-class> 
       org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 
     </filter-class> 

    </filter> 
    <filter-mapping> 
     <filter-name>struts2</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
</web-app> 

User.java

package com.entity; 

import org.apache.struts2.convention.annotation.Action; 
import org.apache.struts2.convention.annotation.Result; 
import org.apache.struts2.convention.annotation.Results; 



import com.opensymphony.xwork2.ActionSupport; 

@Results({ 
     @Result(name="success", location="/welcome.jsp"), 
     @Result(name="input", location="/index.jsp") 
    }) 

public class User extends ActionSupport { 

    private String firstname; 

    private String lastname; 

    public String getFirstname() { 
     return firstname; 
    } 

    public void setFirstname(String firstname) { 
     this.firstname = firstname; 
    } 

    public String getLastname() { 
     return lastname; 
    } 

    public void setLastname(String lastname) { 
     this.lastname = lastname; 
    } 
    @Action(value="reg") 
    public String execute(){ 
     return SUCCESS; 
    } 


} 

的welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!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>Insert title here</title> 
</head> 
<body> 
Welcome 
</body> 
</html> 

请帮我这个代码这个代码中的错误是什么?

+0

你可以更新库,所以至少有一个版本的框架? –

回答

0

user.java文件更改

@Action(value="reg") 
public String execute(){ 
    return SUCCESS; 
} 

@Action(value="/reg") 
public String execute(){ 
    return SUCCESS; 
} 

而且还是那么不工作,请检查您的过滤器类的基础上,采用支柱罐子web.xml中

相关问题