<body部分><div> <div> <input type="button" value="添加" onclick="add()"/></div></div>
<script>
<head部分是><script type="text/javascript">
function add(){
location.href="user!add.action";
}
</script> 但是我运行出来个空值 提示是java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
请问 这是什么原因啊
10 个解决方案
#1
location.href="user!add.action";
改为“window.location.href="user!add.action";
改为“window.location.href="user!add.action";
#2
我改 了 可是还是出那个错误 到底是什么原因呢 帮帮忙 歇息诶了
#3
user!add.action 这里写的对吗!能让我看一下!你后台java 代码吗?
#4
#5
package com.secneo.action;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.secneo.pojo.User;
import com.secneo.service.IUserService;
@Controller("userAction")
@Scope("request")
public class UserAction {
private User user;
private List<User> users;
private IUserService userService;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public IUserService getUserService() {
return userService;
}
@Autowired
public void setUserService(@Qualifier("userService") IUserService userService) {
this.userService = userService;
}
public String add(){
userService.save(user);
return "add";
}
public String list() {
users =userService.findAll();
return "list";
}
public String edit() {
user= userService.findById(user.getId());
return "edit";
}
public String save(){
return list();
}
public String update() {
User u=userService.findById(user.getId());
BeanUtils.copyProperties(user, u);
try {
userService.update(u);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list();
}
public String view(){
user=userService.findById(user.getId());
return "view";
}
public String remove(){
userService.remove(user.getId());
return list();
}
}
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.secneo.pojo.User;
import com.secneo.service.IUserService;
@Controller("userAction")
@Scope("request")
public class UserAction {
private User user;
private List<User> users;
private IUserService userService;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public IUserService getUserService() {
return userService;
}
@Autowired
public void setUserService(@Qualifier("userService") IUserService userService) {
this.userService = userService;
}
public String add(){
userService.save(user);
return "add";
}
public String list() {
users =userService.findAll();
return "list";
}
public String edit() {
user= userService.findById(user.getId());
return "edit";
}
public String save(){
return list();
}
public String update() {
User u=userService.findById(user.getId());
BeanUtils.copyProperties(user, u);
try {
userService.update(u);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list();
}
public String view(){
user=userService.findById(user.getId());
return "view";
}
public String remove(){
userService.remove(user.getId());
return list();
}
}
#6
是不是这个页面的?
#7
java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
方法参数错误 断言失败 这个论点是被需要的 它 不能被赋予null
首先测试程序进入你的action里面没 save 里的 user 根本就是空的 你也不可能 save东西进去吧,,还有return “add” 要对应你的xml文件
方法参数错误 断言失败 这个论点是被需要的 它 不能被赋予null
首先测试程序进入你的action里面没 save 里的 user 根本就是空的 你也不可能 save东西进去吧,,还有return “add” 要对应你的xml文件
#8
都new 出来看下先,是不是没有查出数据
#9
学学高手闷得解答
#10
谢谢高手们的解答
#1
location.href="user!add.action";
改为“window.location.href="user!add.action";
改为“window.location.href="user!add.action";
#2
我改 了 可是还是出那个错误 到底是什么原因呢 帮帮忙 歇息诶了
#3
user!add.action 这里写的对吗!能让我看一下!你后台java 代码吗?
#4
#5
package com.secneo.action;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.secneo.pojo.User;
import com.secneo.service.IUserService;
@Controller("userAction")
@Scope("request")
public class UserAction {
private User user;
private List<User> users;
private IUserService userService;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public IUserService getUserService() {
return userService;
}
@Autowired
public void setUserService(@Qualifier("userService") IUserService userService) {
this.userService = userService;
}
public String add(){
userService.save(user);
return "add";
}
public String list() {
users =userService.findAll();
return "list";
}
public String edit() {
user= userService.findById(user.getId());
return "edit";
}
public String save(){
return list();
}
public String update() {
User u=userService.findById(user.getId());
BeanUtils.copyProperties(user, u);
try {
userService.update(u);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list();
}
public String view(){
user=userService.findById(user.getId());
return "view";
}
public String remove(){
userService.remove(user.getId());
return list();
}
}
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.secneo.pojo.User;
import com.secneo.service.IUserService;
@Controller("userAction")
@Scope("request")
public class UserAction {
private User user;
private List<User> users;
private IUserService userService;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public IUserService getUserService() {
return userService;
}
@Autowired
public void setUserService(@Qualifier("userService") IUserService userService) {
this.userService = userService;
}
public String add(){
userService.save(user);
return "add";
}
public String list() {
users =userService.findAll();
return "list";
}
public String edit() {
user= userService.findById(user.getId());
return "edit";
}
public String save(){
return list();
}
public String update() {
User u=userService.findById(user.getId());
BeanUtils.copyProperties(user, u);
try {
userService.update(u);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list();
}
public String view(){
user=userService.findById(user.getId());
return "view";
}
public String remove(){
userService.remove(user.getId());
return list();
}
}
#6
是不是这个页面的?
#7
java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
方法参数错误 断言失败 这个论点是被需要的 它 不能被赋予null
首先测试程序进入你的action里面没 save 里的 user 根本就是空的 你也不可能 save东西进去吧,,还有return “add” 要对应你的xml文件
方法参数错误 断言失败 这个论点是被需要的 它 不能被赋予null
首先测试程序进入你的action里面没 save 里的 user 根本就是空的 你也不可能 save东西进去吧,,还有return “add” 要对应你的xml文件
#8
都new 出来看下先,是不是没有查出数据
#9
学学高手闷得解答
#10
谢谢高手们的解答