错误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. sublimeText3 中配置sass环境,并将编译后文件保存到指定文件夹

    sass基于ruby引擎,所以安装时ass.compass之前需要安装ruby.具体的链接应该是(http://rubyinstaller.org/downloads).下载并安装相应的版本,勾选第二 ...

  2. Python内置函数(44)——len

    英文文档: len(s) Return the length (the number of items) of an object. The argument may be a sequence (s ...

  3. Linux入门:增加用户,并赋予权限

    一.增加用户 1.增加用户,并指定主目录 # useradd –d /usr/sam -m sam此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录/usr/sam(/us ...

  4. 关于tomcat和jetty的乱码问题

    现象:windows 下的tomcat和jetty默认安装都有问题,linux下的没有问题. 分析:操作系统字符集发生作用了,程序有些处理可能使用了该默认字符集,导致两边现象不一致,建议排查,先尝试通 ...

  5. spring-oauth-server实践:授权方式三:PASSWORD模式下 authorities:ROLE_{user.privillege}, ROLE_USER

    一.数据库配置 1.oauth_client_details 2.user_ 3.user_privillege 二.password模式 授权过程 1.授权者granter和请求参数 Resourc ...

  6. Django 框架介绍

    Django 框架介绍 MVC框架和MTV框架 简单了解一下什么是MVC框架.MVC(Model View Controller),是模型(model)-视图(view)-控制器(controller ...

  7. 复习HTML+CSS(3)

    n  超级链接 l  语法格式:<a 属性 = "值">---</a> l  常用属性: n  Href:目标文件的地址URL,该URL可以是相对地址,也可 ...

  8. React-Native(四):React Native之View学习

    React Native实现以下布局效果:携html5(http://m.ctrip.com/html5/) 基于HelloWord修改项目代码: /** * Sample React Native ...

  9. OS模块文件操作一

    1          文件操作 1.1               OS模块 l  import os  #引入os模块 l  import os.path  #引入os下的path子模块 l  os ...

  10. pyqt4 写动画不能播放问题集合

    最近在学习动画,真的真的是血泪史,百度基本是0资源,各种在谷歌外国大佬的英文中躺过一个一个血坑....... 这是随便写的一个动画功能调试窗口..... 问题现象: 点击食灵,没反应,写的动画不能生成 ...