错误debug后

得到了There is no read method for container的错误

于是我new了一个实体类

 package com.unity;

 public class Student {
private String studentName; public Student(String studentName) {
this.studentName = studentName;
} public String getStudentName() {
return studentName;
}
//
public void setStudentName(String studentName) {
this.studentName = studentName;
}
}

并在action导入

 package com.action;

 import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;
import com.unity.Student; public class HelloWorldAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -7840227232203094654L;
private String studentName; public String getStudentName() {
return studentName;
} public void setStudentName(String studentName) {
this.studentName = studentName;
} private String password; public String execute() {
System.out.println("execute.....");
System.out.println("studentName:" + studentName);
System.out.println("password:" + password);
// ValueStack vs=ActionContext.getContext().getValueStack();
ActionContext context = ActionContext.getContext();
ValueStack vs = context.getValueStack();
// 值栈的栈顶 Student student = new Student("111111"); vs.push(student);
return "info";
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
}
}

虽然没有了There is no read method for container的错误

但是依然无法用el得到值

所以debug可以去死了

后来直接翻墙啃英文的狗屎

发现有一个版本的structs2

默认关了页面的el表达式

强制你使用ognl.........

最终解决方法

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%> //isELIgnored 是否无视el表达式 重新设置为false

但是我后来发现第二个解决方法

同一版本的structs2在不使用maven的情况下

倒没有出现这样的问题

最后总结

为了规范,哥们在maven的情况下,用struts2就用ogln吧,硬是用el加上那句isELIgnored="false"就行了 ,

最后放点取值的方法

         <br> 密码:${password }
<br> 姓名1:<%=request.getParameter("studentName")%>
<br> 姓名2:${studentName}
<br> 姓名3:
<s:property value="[0].studentName" />
<br> 姓名4:
<s:property value="[1].studentName" />
<br> 姓名5:${requestScope.studentName}
 public class HelloWorldAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -7840227232203094654L;
private String studentName; public String getStudentName() {
return studentName;
} public void setStudentName(String studentName) {
this.studentName = studentName;
} private String password; public String execute() {
System.out.println("execute.....");
System.out.println("studentName:" + studentName);
System.out.println("password:" + password);
// ValueStack vs=ActionContext.getContext().getValueStack();
ActionContext context = ActionContext.getContext();
ValueStack vs = context.getValueStack();
// 值栈的栈顶
Student student = new Student("111111");
vs.push(student);
return "info";
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
}
}
 public class Student {
private String studentName; public Student(String studentName) {
this.studentName = studentName;
} public String getStudentName() {
return studentName;
}
//
public void setStudentName(String studentName) {
this.studentName = studentName;
}
}

图片

struts2 可以用ognl拿到值而不可以用el拿到值的解决方法的更多相关文章

  1. 不能将X*类型的值分配到X*类型的实体问题的解决方法

    今天在学习链表的过程中遇到了这个问题,我用如下方法定义了一个结构体,然后这个函数想要在链表头插入一个节点.但是在函数的最后一行却出现了报错:不能将MyLinkedList * 类型的值分配到MyLin ...

  2. Win10 “此环境变量太大。此对话框允许将值设置为最长2047个字符。" 解决方法。

    打开注册表 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment 双击右边的 Path (RE ...

  3. [转]STRUTS2中的OGNL

    OGNL表达式是(Object-Graph Navigation Language)是对象图形化导航语言.OGNL是一个开源的项目,struts2中默认使用OGNL表达式语言来显示数据.与serlve ...

  4. (补充)9.Struts2中的OGNL表达式

    OGNL表达式概述 1. OGNL是Object Graphic Navigation Language(对象图导航语言)的缩写 * 所谓对象图,即以任意一个对象为根,通过OGNL可以访问与这个对象关 ...

  5. .Net调用Java编写的WebServices返回值为Null的解决方法(SoapUI工具测试有返回值)

    最近在项目中与别的公司对接业务,对方是Java语言,需要调用对方的WebServices,结果常规的添加web引用的方法可以传过去值,但是返回值为null 查了很多资料,没有解决方法 思考应该是.Ne ...

  6. 【基于初学者的SSH】struts2 值栈的详解与struts2标签库+ognl表达式

    一:什么是值栈:struts2里面本身提供的一种存储机制,类似于域对象,值栈,可以存值和取值 特点:先进后出,最上面的元素叫做栈顶,也叫压栈. <s:debug></s:debug& ...

  7. struts2中,OGNL访问值栈的时候查找的顺序是什么?请排序:模型对象、临时对象、固定名称的对象、Action对象

    struts2中,OGNL访问值栈的时候查找的顺序是什么?请排序:模型对象.临时对象.固定名称的对象.Action对象 解答:struts2的值栈排列顺序为:1).临时对象:2).模型对象:3).Ac ...

  8. Struts2中的OGNL表达式

    一.OGNL表达式简介 OGNL是Object Graphic Navigation Language(对象图导航语言)的缩写,它是一个开源项目.所谓对象图,即以任意一个对象为根,通过OGNL可以访问 ...

  9. Struts2入门(五)——OGNL和标签库

    一.前言 OGNL和标签库的作用,粗暴一点说,就是减少在JSP页面中出现java代码,利于维护. 1.1.OGNL 1.1.1.什么是OGNL? OGNL(Object-Graph Navigatio ...

随机推荐

  1. Python内置函数(20)——hex

    英文文档: hex(x) Convert an integer number to a lowercase hexadecimal string prefixed with "0x" ...

  2. 安装 docker-compose

    安装Docker-Compose之前,请先安装 python-pip,安装好pip之后,就可以安装Docker-Compose了. 一.检查是否已经安装 二.安装 docker-compose 1.安 ...

  3. GIT入门笔记(2)- 典型的工作模式

      分布式相比于集中式的最大区别在于开发者可以提交到本地,每个开发者通过克隆(git clone),在本地机器上拷贝一个完整的Git仓库.   下图是经典的git开发过程.   Git的功能特性:   ...

  4. requests-get请求

    import requests response= requests.get('http://www.baidu.com')#get方法请求网址 print(response) print(respo ...

  5. digest-MD5认证

    digest-MD5认证机制是基于MD5算法的LINUX安全机制认证. 会比较用户端传送的杂凑值与使用者密码的杂凑值,以认证用户端. 但由于此机制必须读取使用者密码,因此,所有想透过digest-MD ...

  6. jacascript 判断元素尺寸和位置

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! getBoundingClientRect() 判断一个元素的尺寸和位置是简单的方法就是使用 obj.ge ...

  7. Spring源码分析:Spring IOC容器初始化

    概述: Spring 对于Java 开发来说,以及算得上非常基础并且核心的框架了,在有一定开发经验后,阅读源码能更好的提高我们的编码能力并且让我们对其更加理解.俗话说知己知彼,百战不殆.当你对Spri ...

  8. Linux 文件读写操作与磁盘挂载

    文件读写 [文件描述符] Linux下,通常通过open打开一个文件,它然后返回给我们一个整数,通过这个整数便可以操作文件,这个整数我们称文件描述符(fd).对应被打开的文件,它也是一种系统资源,那么 ...

  9. Java基础学习(五)-- Java中常用的工具类、枚举、Java中的单例模式之详解

    Java中的常用类 1.Math : 位于java.lang包中 (1)Math.PI:返回一个最接近圆周率的 (2)Math.abs(-10):返回一个数的绝对值 (3)Math.cbrt(27): ...

  10. eclipse下maven插件搭建springmvc之helloworld

    这几天学习了怎样使用maven,最终还是要回归web项目嘛,所以主要还是使用eclipse插件. 1 下载eclipse maven插件. 其实新版的eclipse已经集成了maven:lunar.m ...