我用一般属性方法和domain model都无法接收到参数,不知道是为何,自己查阅资料也无解..请各位大侠指正.
这个程序主要是从前台的html传入一个参数,让structs2自动接受,并把参数打印出来到服务器(容器),不知哪地方问题一直
接收不到,name=null...domain model也是如此,npe错误.<?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"><struts> <constant name="struts.devMode" value="true" />
<package name="default" namespace="/Char" extends="struts-default">
        <action name="CharactorEncodingAction" class="com.lee.structs.UserAction">
            <result>
             /Test.jsp
            </result>
            
        </action>
    </package>
    <!-- Add packages here -->

</struts>
package com.lee.structs;
import com.opensymphony.xwork2.ActionSupport;
import com.lee.structs.*;public class UserAction extends ActionSupport {// private User user;
private String name;

// public User getUser() {
// return user;
// }// public void setUser(User user) {
// this.user = user;
// }
// public String execute() {
// System.out.println(user.getName());
// return "success";
//
// } public String execute() {
System.out.println("name= " + name);
return "success";

}

public String add(){
return "add";
}

public String delete(){
return "delete";
}
}<!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=UTF-8">
<title>CharactorEncoding</title>
<base href="http://localhost:8080/Structs2_00_CharactorEncoding/">
</head>
<body>
<form action="Char/CharactorEncodingAction" method="get">
<input type="text" name="name"></input>
<input type="submit" value="submit" ></input>
</form>
</body>
</html>