struts2 Action 实现了ServletRequestAware接口,但是获取不到request对象实例

struts2 的 Action 实现了ServletRequestAware接口,但是获取不到HttpServletRequest对象实例

2个回答

需要在struts.xml配置文件中对相应的action加上拦截器引用:[code="xml"][/code]

[quote]struts2 的 Action 实现了ServletRequestAware接口,但是获取不到HttpServletRequest对象实例 [/quote]
[color=blue]
[b]要实现接口方法:[/b][/color]
[code="java"] private ServletContext context;
public void setServletContext(ServletContext context) {

   this.context = context;  
}  [/code]

[color=blue]
[b]另外确保你的interceptorStack中含有[/b][/color]

[code="xml"] [/code]

[color=blue][b]最后,是不是InterceptorStack中的在servletConfig前面的Interceptor,已经做出了转向,即直接返回了result,后续Interceptor不再被调用[/b][/color]

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
如何在struts2中 对指定Action的方法进行框架(xml)校验?
问题描述: 1. 保存在线咨询功能 2. Action的保存方法是 addConsult() 3. 进行struts2的框架校验 校验规则配置在 WebConsultManagerAction-validation.xml 4. 要求校验规则只对 addConsult() 方法进行有效 WebConsultManagerAction 类如下: [code="java"]package com.teamax.web.struts.action; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.interceptor.ServletRequestAware; import com.opensymphony.xwork2.ActionSupport; import com.teamax.web.service.WebConsultService; import com.teamax.web.struts.actionForm.WebConsultForm; import com.teamax.web.util.IPUtils; /** * @author 作者:qiuzq * E-mail:qzq_hello@163.com * @version * 创建时间:Mar 23, 2009 4:05:30 PM * 类说明: 在线咨询 * 修改记录: */ public class WebConsultManagerAction extends ActionSupport implements ServletRequestAware{ private static final long serialVersionUID = -8789596114574032277L; private static final WebConsultService webConsultService = new WebConsultService(); private WebConsultForm webConsultForm = new WebConsultForm(); private HttpServletRequest request; public void setServletRequest(HttpServletRequest request) { this.request = request; } public WebConsultForm getWebConsultForm() { return webConsultForm; } public void setWebConsultForm(WebConsultForm webConsultForm) { this.webConsultForm = webConsultForm; } //增加在线咨询 public String addConsult() { webConsultForm.setUserip(IPUtils.getIpAddr(this.request)); webConsultService.addConsult(webConsultForm); return SUCCESS; } }[/code] WebConsultManagerAction-validation.xml 校验规则如下: [code="java"]<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> <validators> <field name="webConsultForm.title"> <field-validator type="requiredstring"> <param name="trim">true</param> <message key="consultForm.title" /> </field-validator> </field> <field name="webConsultForm.usercontent"> <field-validator type="requiredstring"> <param name="trim">true</param> <message key="consultForm.usercontent" /> </field-validator> </field> <field name="webConsultForm.ccode"> <field-validator type="requiredstring"> <param name="trim">true</param> <message key="consultForm.ccode" /> </field-validator> </field> </validators>[/code]
spring 如何给struts2的action设置request对象的?详情见全文
在ioc环境里,在一个UserAction 要获得 request对象,可以这么实现: <br />让UserAction 实现ServletRequestAware接口,然后在UserAction里面写下面这个方法: <br />public HttpServletRequest request;//定义request属性 <br />public void setServletRequest(HttpServletRequest request) { <br /> this.request = request; <br /> } <br />就这样可以正确使用request。 <br />然而我的问题是什么呢? 是spring是如何给这个request赋值的? 我想知道spring内部是如何实现的? <br />实现这个接口后,spring 是如何给他赋值的? <br />请高手解释? <br />我的理解 是spring用了动态代理实现的,不知道对不对?<br/><strong>问题补充</strong><br/><div class="quote_title">java_bigniu 写道</div><div class="quote_div">HttpServletRequest request = ServletActionContext.getRequest(); </div> <br />我想知道,spring在哪里给他赋值的?我想知道spring内部的代码,哪块处理的?原理是什么? <br />你的这个方式是在非ioc的方式下获得request对象的<br/><strong>问题补充</strong><br/>其实我的意思,想明白咱们实现spring的这个接口后,spring内部是如何处理这个的? 为什么我实现这个接口后, <br />public void setServletRequest(HttpServletRequest request) { <br />this.request = request; <br />} <br />这个方法的参数HttpServletRequest request 是从哪儿传来的? <br />request 是怎么生成的?<br/><strong>问题补充</strong><br/><div class="quote_title">kjj 写道</div><div class="quote_div">晕,这有啥难的,你忘了,spring的容器是怎么初始化的么,web就是webapplicationcontext,所以,每次请求这个对象的时候,把当前线程的requet注入了</div> <br />呵呵,我知道不难,我就明白,spring内部是如何实现的?在哪个类里面注入的?我看了源代码,没找到在哪儿注入啊?<strong>是动态代理实现的。</strong> <br /> <br />还有,这个问题不仅仅在spring里面有,在jdk里面也很普遍啊,比如让你实现某个接口,就能得到某个功能。他内部肯定是用动态代理实现的,特别是这个接口有参数的时候,这个参数就是动态代理传进来的。基于接口的就是动态代理才能实现。 <br /> <br /><br/><strong>问题补充</strong><br/><div class="quote_title">kjj 写道</div><div class="quote_div">晕,这有啥难的,你忘了,spring的容器是怎么初始化的么,web就是webapplicationcontext,所以,每次请求这个对象的时候,把当前线程的requet注入了</div> <br /> <br />你的意思是 有个监听器:org.springframework.web.context.request.RequestContextListener <br />这个监听到后,会注入?<br/><strong>问题补充</strong><br/><div class="quote_title">Aaronlong31 写道</div><div class="quote_div">这个和spring有什么关系吗?是struts2的拦截器处理的,在struts2的默认拦截器栈中有个ServletConfigInterceptor,它会判断你是否实现了ServletRequestAware接口,如果实现了,它就帮你注入HttpServletRequest对象,这样的Aware接口还有很多,如SessionAware等。</div> <br /> <br />那他的注入也是通过spring的ioc注入的,怎么没关呢? <br />在ioc下是实现接口可以获得request,非ioc下直接获得就行了,不用实现接口的。<br/><strong>问题补充</strong><br/><div class="quote_title">rentianchou 写道</div><div class="quote_div">么人所让你非得实现接口啊</div> <br />嗨,标题讨论就是讨论ioc下面的情况,。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 <br />总之感谢大家一起交流了。<br/><strong>问题补充</strong><br/><div class="quote_title">池中物 写道</div><div class="quote_div">这个跟spring没关系,是struts做的</div> <br />明白,呵呵。拦截器的原理也是动态代理实现的,我说的没错。<br/><strong>问题补充</strong><br/>ok 明白了<br/><strong>问题补充</strong><br/>不是的,但是动态代理用的很多,aop 拦截器 filter 都是动态代理<br/><strong>问题补充</strong><br/>究其本质还是 动态代理,就是struts2的这个拦截器ServletConfigInterceptor,本质也是动态代理实现的,我说的有错吗?和动态代理能脱离关系吗?<br/><strong>问题补充</strong><br/>不是我和动态代理脱不了关系,是他们的原理实现就是这样的,我是这么理解的。
struts2在ACTION中给checkboxlist赋值
[code="java"] action中 FreightPolicyQueryAction extends ActionSupport implements ServletRequestAware, ModelDriven<FreightPolicyQueryModel> ..... String[] insurance = new String[2]; insurance[0] = "1"; insurance[1] = "2"; LOG.info(insurance.length); getModel().setInsurance(insurance);//给驱动模型设置值 if (getModel().getInsurance() != null) { LOG.info(getModel().getInsurance().length); for (int i = 0; i < getModel().getInsurance().length; i++) { LOG.info(getModel().getInsurance()[i]); } } return "fpQueryInit"; [/code] [code="java"] <td width="75%"> <s:checkboxlist name="insurance" theme="simple" labelposition="right" list="#{'1':'国内','2':'进口'}" listKey="key" listValue="value"></s:checkboxlist> </td> [/code] 想实现的就是从action中给jsp设置checkboxlist的值...网上找了一下,好象设置同名的数组就可以了.我的insurance是在modeldriven中写的.
一个用spring aop拦截struts action的问题
最近我需要在不改变原有的代码的前提下,记录到达struts action的HttpServletRequest和HttpServletResponse,我的第一想法就是用spring aop来做拦截。但是,这样做使得原来struts action无法获得struts上下文的内容信息,为了说明问题,我写了一个小原型,代码如下: [color=red]类SimpleAction,这个类是用来封装获得HttpServletRequest和HttpServletResponse的方法的,跟本主题关系不大,可以跳过。[/color] package action; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import org.apache.struts2.interceptor.SessionAware; import com.opensymphony.xwork2.ActionSupport; public class SimpleAction extends ActionSupport implements ServletRequestAware, ServletResponseAware ,SessionAware{ protected HttpServletRequest servletRequest; protected HttpServletResponse servletResponse; protected Map session; public Map getSession() { return session; } public void setSession(Map session) { this.session = session; } public void setServletRequest(HttpServletRequest request) { this.servletRequest = request; } public HttpServletRequest getServletRequest() { return this.servletRequest; } public void setServletResponse(HttpServletResponse response) { this.servletResponse = response; } public HttpServletResponse getServletResponse() { return this.servletResponse; } } 类LoginAction,这个类的execute就是struts处理action调用的方法,但是奇怪的是,在这个方法中,本应得到jsp传来的值得username和password为空(把spring aop相关配置注释掉之后,username和password能正常传值)。loginService.validate()用作判断username和password是否符合,不符合以抛出异常的方式来告知调用者。在加上spring aop后,由于[color=red]username和password为空[/color],所以就一直返回结果"usernameInvalid"。 package action; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import org.apache.struts2.interceptor.SessionAware; import service.LoginService; import exception.*; public class LoginAction extends SimpleAction { private String username; private String password; private LoginService loginService; public LoginService getLoginService() { return loginService; } public void setLoginService(LoginService loginService) { this.loginService = loginService; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public void validate() { } @Override public String execute() { try{ this.getServletRequest().setAttribute("username", username); this.getServletRequest().setAttribute("password", password); System.out.println("username"+username); System.out.println("username"+getUsername()); boolean result = loginService.validate(username, password); }catch(UsernameException ue) { return "usernameInvalid"; }catch(PasswordException pe) { return "passwordInvalid"; }catch(Exception e) { e.printStackTrace(); return INPUT; } return SUCCESS; } } 下面是advice类,用来处理调用方法后的日志记录工作 package advice; import java.io.*; import java.lang.reflect.Method; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.springframework.aop.AfterReturningAdvice; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.ThrowsAdvice; public class LogActionAdvice implements AfterReturningAdvice { public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object target) { // TODO Auto-generated method stub try { PropertyConfigurator.configure("after.properties"); Logger logger = Logger.getLogger(target.getClass()); logger.debug("..."); }catch(Exception e) { e.printStackTrace(); } } } 下面是login页面,这个页面的username空间对应action的username属性,所以应该不是struts没有配alias的问题,这里是login.jsp代码 <%@ page language="java" pageEncoding="GB2312"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//CN"> <html> <head> <title>login2</title> </head> <body> <s:form name="login" action="login" method="post" > <s:textfield name="username" label="帐号"></s:textfield> <s:password name="password" label="密码"></s:password> <s:submit></s:submit> </s:form> </body> </html> 下面是配置文件,首先是struts的配置文件struts.xml: <?xml version="1.0" encoding="GB2312" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="struts2" extends="struts-default"> <action name="login" class="LoginAction"> <result name="success">/index.jsp</result> <result name="input">/login.jsp</result> <result name="usernameInvalid">/usernameInvalid.jsp</result> <result name="passwordInvalid">/passwordInvalid.jsp</result> </action> </package> </struts> 再来是spring的配置文件applicationContext.xml,红色部分是advice的配置,具体是匹配所有*Action的execute方法。 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:ehcache="http://www.springmodules.org/schema/ehcache" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd" default-lazy-init="true" default-autowire="byName"> [color=red] <aop:config> <aop:advisor id="methodAroundAdviceAdvisor" advice-ref="logActionAdvice" pointcut="execution(* *..*Action.execute(..))" /> </aop:config> <bean id="logActionAdvice" class="advice.LogActionAdvice" />[/color] <bean name="loginService" class="service.LoginService" /> <bean name="LoginAction" class="action.LoginAction"> <property name="loginService"> <ref bean="loginService"/> </property> </bean> </beans> 最后是web.xml的源码: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 加载struts2核心 --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 指明spring配置文件在何处 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 加载spring配置文件applicationContext.xml --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> </web-app> 在这个原型中出现的问题是,在LoginAction中,username和password为空,但是,[color=red]如果把它们set到 HttpServletRequest中,在页面usernameInvalid.jsp中却能够得到username和password的值。[/color]事先我查过一些资料,说用spring aop自动生成的代理无法获得struts上下文传递的变量值,但是我想不通为何把它们set到HttpServletRequest后却能够在前端页面显示出正确的值。 谢谢您的阅读和帮助!
struts基础之指定method属性的动态方法调用
![图片说明](https://img-ask.csdn.net/upload/201704/30/1493562750_865793.png) HelloWorldAction.java: ``` package com.imooc.action; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import org.apache.struts2.util.ServletContextAware; import com.opensymphony.xwork2.ActionSupport; public class HelloWorldAction extends ActionSupport implements ServletRequestAware,ServletResponseAware,ServletContextAware{ private HttpServletRequest request; public String add(){ return SUCCESS; } public String update(){ return SUCCESS; } @Override public String execute() throws Exception { System.out.println("执行action"); return SUCCESS; } @Override public void setServletResponse(HttpServletResponse arg0) { } @Override public void setServletRequest(HttpServletRequest request) { this.request=request; } @Override public void setServletContext(ServletContext arg0) { } } ``` struts.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="default" namespace="/" extends="struts-default"> <action name="helloworld" class="com.imooc.action.HelloWorldAction"> <result>/result.jsp</result> </action> <action name="addAction" method="add" class="com.imooc.action.HelloWorldAction"> <result>/add.jsp</result> </action> <action name="updateAction" method="update" class="com.imooc.action.HelloWorldAction"> <result>/update.jsp</result> </action> </package> </struts> ``` web.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>test</display-name> <welcome-file-list> <welcome-file>index.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> ``` add.jsp: ``` <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <html> <head> <title></title> </head> <body> this is add.jsp </body> </html> ``` update.jsp: ``` <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <html> <head> <title></title> </head> <body> this is update.jsp </body> </html> ``` result.jsp: ``` <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <html> <head> <title></title> </head> <body> this is result.jsp </body> </html> ``` http://localhost:8080/test/helloworld.action能正常显示。 http://localhost:8080/test/addAction.action和http://localhost:8080/test/updateAction.action出现错误信息; HTTP Status 404 - There is no Action mapped for namespace [/] and action name [helloworld_add] associated with context path [/test]. 和 HTTP Status 404 - There is no Action mapped for namespace [/] and action name [updateAction] associated with context path [/test].
struts2模型驱动方式action获取不到表单数据。
拦截器: ``` public class SuperAction extends ActionSupport implements ServletRequestAware,ServletResponseAware,ServletContextAware{ private static final long serialVersionUID = 1L; protected HttpServletRequest request; protected HttpServletResponse response; protected HttpSession session; protected ServletContext application; @Override public void setServletContext(ServletContext application) { this.application=application; } @Override public void setServletResponse(HttpServletResponse response) { this.response=response; } @Override public void setServletRequest(HttpServletRequest request) { this.request=request; this.session=this.request.getSession(); } } ``` 模型驱动方式获取user数据 ``` public class UsersAction extends SuperAction implements ModelDriven<Users> { private static final long serialVersionUID = 1L; private Users user =new Users(); @Override public Users getModel() { return this.user; } // 用户登录动作 public String login() { UsersDao userDao = new UsersDaoImpl(); if(this.user!=null){ if (userDao.userLogin(this.user)) { return "login_success"; } else { return "login_failure"; } } return "login_failure"; } } ``` user: ``` public class Users { private int userId; private String userName; private String realName; private String userPwd; private String tel; private String mark; private Date regTime; private Date updateTime; .......省略getter和setter ``` 配置 ``` <package name="users" namespace="/" extends="default"> <action name="*_*" class="action.{1}Action" method="{2}"> <result name="login_success">/index.jsp</result> <result name="login_failure">/login.jsp</result> <result name="reg_success">/login.jsp</result> <result name="reg_failure">/reg.jsp</result> </action> </package> ``` jsp页面在根路径: 表单: <form action="<%=path%>/Users_login.action" method="post" id="login"> <label class="label1"> <span class="lab1"></span> <input type="text" id="name" name="name" maxlength="20" placeholder="请输入您的用户名"/> </label> <!-- name error tip begin--> <label class="label2"> <span class="lab2"></span> <input type="password" name="pwd" id="pwd" maxlength="20" placeholder="请输入您的密码" /> </label> <!-- password error tip begin--> <input type="submit" value="" id="sub" /> </form>
后台通过ServletRequestAware获得数据后,怎么在前端jsp显示
下面是action代码: public class test2_action extends ActionSupport implements ServletRequestAware{ private test2_bill bill; private String name; private String pass; public test2_bill getBill() { return bill; } public void setBill(test2_bill bill) { this.bill = bill; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPass() { return pass; } public void setPass(String pass) { this.pass = pass; } public String login() { ArrayList<test2> list = bill.list(); System.out.println("action++"+list.size()); req.setAttribute("clientslist", list); // req.put("clientlist", list); // ActionContext.getContext().getSession().put("clientslist", list); return SUCCESS; } HttpServletRequest req; @Override public void setServletRequest(HttpServletRequest arg0) { // TODO Auto-generated method stub req=arg0; } } 我前端代码: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@taglib uri="/struts-tags" prefix="s"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <div align="center"> <table border="1" bgColor="#d0d0d0" cellspacing="1" cellpadding="1"> <tr> <td>id</td><td>名称</td><td>密码</td> </tr> <script language="JavaScript"> alert(); </script> <s:iterator value="#request.clientslist" var="item"> <tr> <td><s:property value="#item.id"></s:property> </td> <td><s:property value="#item.name"></s:property> </td> <td><s:property value="#item.pass"></s:property> </td> <td> </tr> </s:iterator> </table> </div> </body> </html>
struts2问题
本人在测试Struts2.0中的表达式语言的时候,程序频频报空指针的错误,可是检查却好像并没有什么错误啊!还真是郁闷了,现在贴出来想和大家一起探讨一下: 首先是一个Book类: package tutorial.model; public class Book { private String isbn; private String title; private double price; public Book() { } public Book(String isbn,String title,dobule price) { this.isbn = isbn; this.title = title; this.price = price; } public String getIsbn() { return isbn; } public void setIsbn(String isbn) { this.isbn = isbn; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } Action类: BookAction.java package tutorial.action import java.util.LinkedList; import java.util.List; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.SessionAware; import org.apache.struts2.util.ServletContextAware; import tutorial.model.Book; import com.opensymphony.xwork2.ActionSupport; public class OgnlAction extends ActionSupport implements ServletRequestAware,SessionAware,ServletContextAware { private static final long serialVersionUID = 1L; private HttpServletRequest request; private Map <String,String> session; private ServletContext application; private List <Book> books; public void setServletRequest(HttpServletRequest request) { this.request = request; } @SuppressWarnings("unchecked") public void setSession(Map session) { this.session = session; } public void setServletContext(ServletContext application) { this.application = application; } public List <Book> getBooks() { return books; } @Override public String execute() { request.setAttribute("userName","Max From request"); session.put("userName","Max From session"); application.setAttribute("userName","Max From application"); books = new LinkedList <Book>(); books.add(new Book("978-0735619678", "Code Complete, Second Edition", 32.99)); books.add(new Book("978-0596007867", "The Art of Project Management", 35.96)); books.add(new Book("978-0201633610", "Design Patterns: Elements of Reusable Object-Oriented Software", 43.19)); books.add(new Book("978-0596527341", "Information Architecture for the World Wide Web: Designing Large-Scale Web Sites", 25.19)); books.add(new Book("978-0735605350", "Software Estimation: Demystifying the Black Art", 25.19)); return SUCCESS; } } Ognl.jsp <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href=" <%=basePath%>"> <title>Struts OGNL Demo </title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <h3>访问OGNL上下文和Action上下文 </h3> <p>parameters: <s:property value="#parameters.userName"/> </p> <p>request.userName: <s:property value="#request.userName"/> </p> <p>session.userName: <s:property value="#session.userName"/> </p> <p>application.userName: <s:property value="#application.userName"/> </p> <p>attr.userName: <s:property value="#attr.userName"/> </p> <hr/> <h3>用于过滤和投影集合 </h3> <p>Books more than $35 </p> <ul> <s:iterator value="books.{?#this.price>35}"> <li> <s:property value="title"/>-$ <s:property value="price"/> </li> </s:iterator> </ul> <p> The price of "Code Complete,Second Edition"is: <s:property value="books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]"/> </p> <hr/> <h3>构造Map </h3> <s:set name="foobar" value="#{'foo1':'bar1','foo2':'bar2'}"/> <p>The value of key "foo1" is <s:property value="#foobar['foo1']"/> </p> </body> </html> web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Struts2 OGNL </display-name> <filter> <filter-name>struts-cleanup </filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp </filter-class> </filter> <filter-mapping> <filter-name>struts-cleanup </filter-name> <url-pattern>/* </url-pattern> </filter-mapping> <filter> <filter-name>struts2 </filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2 </filter-name> <url-pattern>/* </url-pattern> </filter-mapping> </web-app> struts.xml <?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="Struts-OGNL-DEMO" extends="struts-default"> <action name="Ognl" class="tutorial.action.OgnlAction"> <result>/Ognl.jsp </result> </action> </package> </struts> 全部错误信息: 2008-7-5 11:17:13 org.apache.catalina.core.AprLifecycleListener init 信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.5.0_06\bin;D:\Program Files\apache-tomcat-6.0.10\bin 2008-7-5 11:17:14 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on http-8087 2008-7-5 11:17:14 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 781 ms 2008-7-5 11:17:14 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2008-7-5 11:17:14 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.10 2008-7-5 11:17:15 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextInitialized() 2008-7-5 11:17:15 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextInitialized() 2008-7-5 11:17:16 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register 信息: Parsing configuration file [struts-default.xml] 2008-7-5 11:17:16 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register 信息: Parsing configuration file [struts-plugin.xml] 2008-7-5 11:17:16 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register 信息: Parsing configuration file [struts.xml] 2008-7-5 11:17:16 org.apache.struts2.config.Settings getLocale 警告: Settings: Could not parse struts.locale setting, substituting default VM locale 2008-7-5 11:17:16 com.opensymphony.xwork2.config.impl.DefaultConfiguration$ContainerProperties setProperty 信息: Overriding property struts.i18n.reload - old value: false new value: true 2008-7-5 11:17:16 com.opensymphony.xwork2.config.impl.DefaultConfiguration$ContainerProperties setProperty 信息: Overriding property struts.configuration.xml.reload - old value: false new value: true 2008-7-5 11:17:17 com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory <clinit> 信息: Setting DefaultObjectTypeDeterminer as default ... 2008-7-5 11:17:17 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8087 2008-7-5 11:17:17 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2008-7-5 11:17:17 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/47 config=null 2008-7-5 11:17:17 org.apache.catalina.startup.Catalina start 信息: Server startup in 3328 ms 2008-7-5 11:17:27 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578)f\ at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 11:17:27 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 11:17:27 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 11:17:27 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:18 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:18 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:19 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:19 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:22 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:22 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:22 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:22 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:23 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:24 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:24 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:24 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:24 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at ognl.Ognl.getValue(Ognl.java:310) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:208) at org.apache.struts2.components.Component.findValue(Component.java:254) at org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:210) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fiterator_005f0(Ognl_jsp.java:257) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.title=='Code Complete,Second Edition'}.{price}[0]' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.ASTChain.getValueBody(ASTChain.java:109) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210) at ognl.Ognl.getValue(Ognl.java:333) at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194) at com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:238) at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.Ognl_jsp._jspx_meth_s_005fproperty_005f7(Ognl_jsp.java:339) at org.apache.jsp.Ognl_jsp._jspService(Ognl_jsp.java:124) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:595) 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: NOTE: Previous warning message was issued due to devMode set to true. 2008-7-5 16:30:25 com.opensymphony.xwork2.util.OgnlValueStack logLookupFailure 警告: Caught an exception while evaluating expression 'books.{?#this.price>35}' against value stack java.lang.NullPointerException at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:147) at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1578) at ognl.OgnlRuntime.getElementsAccessor(OgnlRuntime.java:1545) at ognl.ASTSelect.getValueBody(ASTSelect.java:53) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at ognl.SimpleNode.getValue(SimpleNode.java:210)
sturts2中request问题 待高手
我是这样的,我想把action与model分离,在action里实现了ModelDriven,ServletRequestAware 接口,然后发布项目,在输出页面能获取到值。但我想要把model里User 类中的所有值都保存在一个session里,然后在其他非servlet里取值,但 就不行了,要怎么解决,或者还有其他方式没?
action继承ActionSupport后action不能访问特定的方法是为什么
表单的action为: 《form action="login.action">《/form> struts2.xml的配置为: 《action name="login" class="loginAction" method="userLogin"》 《result name="ok"》index.jsp《/result》 《result name="error"》login.jsp《/result》 《/action》 LoginAction的代码为: public class LoginAction extends ActionSupport implements ServletRequestAware{ private static final long serialVersionUID = 1L; private HttpServletRequest req; private LoginServiceinter loginServiceImp; @Override public String execute() throws Exception { System.out.println("进入默认方法"); return "ok"; } public String userLogin(){ Users user = loginServiceImp.userLogin(req.getParameter("username"), req.getParameter("password")); if(user!=null){ req.getSession().setAttribute("userid", user.getUserId()); req.getSession().setAttribute("username", user.getUsername()); return "ok"; } return "error"; } @Override public void setServletRequest(HttpServletRequest arg0) { this.req = arg0; } } 结果访问不到 HTTP Status 404 - No result defined for action com.zui2jun.action.LoginAction and result ok 控制台提示: 进入默认方法 如果将form改成《form action="asdf.action"》 struts.xml改成 《action name="asdf" class="loginAction" method="asdf"》 《result name="ok">/index.jsp</result》 《result name="error">/login.jsp</result》 《/action》 方法名改成 public String asdf(){ Users user = loginServiceImp.userLogin(req.getParameter("username"), req.getParameter("password")); if(user!=null){ req.getSession().setAttribute("userid", user.getUserId()); req.getSession().setAttribute("username", user.getUsername()); return "ok"; } return "error"; } 就可以正常访问 是为什么?
struts2中add cookie 不能再客户端生成cookie文件,为什么?
我做自动登录的功能,是这样操作的: [code="java"] package com.zuwoba.presentation.action.account; import java.util.Map; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsStatics; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import com.opensymphony.xwork2.ActionContext; import com.zuwoba.model.User; import com.zuwoba.model.UserSession; import com.zuwoba.presentation.action.base.BaseAction; import com.zuwoba.util.EmailLoginAddress; import com.zuwoba.util.MD5_Encoding; /** * @project_name zuwoba * @file_name LoginAction.java * @author tianhandigeng * @version Oct 25, 2010 2:53:04 PM * @declaration */ public class LoginAction extends BaseAction implements ServletRequestAware,ServletResponseAware{ private String email_username; private String password; private String captcha; private String autologin; private HttpServletRequest request; private HttpServletResponse response; // 提示窗口 private String hint; private String tip; public String getTip() { return tip; } public void setTip(String tip) { this.tip = tip; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getAutologin() { return autologin; } public void setAutologin(String autologin) { this.autologin = autologin; } public String getEmail_username() { return email_username; } public void setEmail_username(String email_username) { this.email_username = email_username; } public String getHint() { return hint; } public void setHint(String hint) { this.hint = hint; } public String getCaptcha() { return captcha; } public void setCaptcha(String captcha) { this.captcha = captcha; } public void setServletRequest(HttpServletRequest servletRequest) { this.request=servletRequest; } public void setServletResponse(HttpServletResponse servletResponse) { this.response=servletResponse; } @SuppressWarnings("unchecked") public String execute() { //// HttpServletResponse response = (HttpServletResponse) ActionContext //// .getContext().get(StrutsStatics.HTTP_RESPONSE); //// HttpServletRequest request = (HttpServletRequest) ActionContext //// .getContext().get(StrutsStatics.HTTP_REQUEST); //// HttpSession session = request.getSession(); // HttpServletResponse response=(HttpServletResponse)ServletActionContext.getResponse(); // HttpServletRequest request=(HttpServletRequest)ServletActionContext.getRequest(); HttpSession session=request.getSession(); //获得域名 // String host=request.getServerName(); String host="ceshi"; email_username = this.getEmail_username().trim(); password = this.getPassword().trim(); captcha = this.getCaptcha().trim().toLowerCase(); autologin = this.getAutologin(); // 密码加密 MD5_Encoding md5 = new MD5_Encoding(); password = md5.getMD5ofStr(password); if (!captcha.equals(session.getAttribute("idcode"))) { this.setTip("验证码错误"); this.setHint("failed"); return INPUT; } else { // Email登录 User user1 = userService.findUserByEmailPassword(email_username, password); if (user1 != null) { if ("N".equals(user1.getEnable())) {// 邮件登陆但没有激活 String emailAddress = EmailLoginAddress .getEmialLoginAddress(email_username); session.setAttribute("email", email_username); session.setAttribute("secret", user1.getSecret()); session.setAttribute("tempname", user1.getUsername()); session.setAttribute("emailAddress", emailAddress); return "unverified"; } else { // 处理自动登录 if (autologin != null) { // 创建两个cookie对象 // 一个cookie记录用户名,另一个记录唯一的验证码 // 并将此验证码写入数据库,以备用户返回时查询(防止伪造cookie) Cookie cookie1 = new Cookie("SESSION_LOGIN_USERNAME", user1 .getUsername()); cookie1.setMaxAge(60 * 60 * 24 * 14);// 设置cookie有效期为2周 cookie1.setPath("/"); cookie1.setDomain(host); response.addCookie(cookie1); String sessionid = session.getId(); Cookie cookie2 = new Cookie("SESSION_ID", sessionid); cookie2.setMaxAge(60 * 60 * 24 * 14); cookie2.setPath("/"); cookie2.setDomain(host); response.addCookie(cookie2); // 在数据库中插入相应记录 UserSession userSession = new UserSession(); userSession.setUsername(user1.getUsername()); userSession.setSessionid(sessionid); userService.addUserSession(userSession); } session.setAttribute("user", user1); return SUCCESS; } } else { // 用户名登陆 User user2 = userService.findUserByUserNamePassword( email_username, password); if (user2 != null) { if ("N".equals(user2.getEnable())) {// 用户名登陆但没有激活 String emailAddress = EmailLoginAddress .getEmialLoginAddress(email_username); session.setAttribute("email", email_username); session.setAttribute("secret", user2.getSecret()); session.setAttribute("tempname", user2.getUsername()); session.setAttribute("emailAddress", emailAddress); return "unverified"; } else { // 处理自动登录 if (autologin != null) { // 创建两个cookie对象 // 一个cookie记录用户名,另一个记录唯一的验证码 // 并将此验证码写入数据库,以备用户返回时查询(防止伪造cookie) Cookie cookie1 = new Cookie("SESSION_LOGIN_USERNAME", user2 .getUsername()); cookie1.setMaxAge(60*60*24*14);// 设置cookie有效期为2周 cookie1.setPath("/"); cookie1.setDomain(host); response.addCookie(cookie1); String sessionid = session.getId(); Cookie cookie2 = new Cookie("SESSION_ID", sessionid); cookie2.setMaxAge(60 * 60 * 24 * 14); cookie2.setPath("/"); cookie2.setDomain(host); response.addCookie(cookie2); // 在数据库中插入相应记录 UserSession userSession = new UserSession(); userSession.setUsername(user2.getUsername()); userSession.setSessionid(sessionid); userService.addUserSession(userSession); } session.setAttribute("user", user2); return SUCCESS; } } else { this.setHint("failed"); this.setTip("不存在这样的Email或用户名或密码错误"); return INPUT; } } } } } [/code] 奇怪的是,客户端就是不能生成cookie文件,我真的不知道是为什么了,哪位大哥分析一下是什么原因,小弟感激不尽
java.lang.OutOfMemoryError: PermGen space
在服务器中添加一个SSH项目时,服务器运行一段时间后报错。 错误如下: 三月 06, 2017 5:45:50 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 21784 ms 三月 06, 2017 5:46:35 下午 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 三月 06, 2017 6:41:24 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom 信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [468] milliseconds. 三月 06, 2017 7:00:53 下午 org.quartz.core.JobRunShell run 严重: Job HtmlChannelJob.HtmlChannelJob8757c397-a53d-4c3d-84a0-929aac8e6db5 threw an unhandled Exception: java.lang.OutOfMemoryError: PermGen space 原服务器中有2个项目,把新加的项目war包直接放入webapps中。运行几个小时后出现了内存溢出的错误。 服务器tomcat配置如下![图片说明](https://img-ask.csdn.net/upload/201703/07/1488857464_691095.png) 新加的SSH项目有 excl导入导出功能,代码如下: ``` package zcib.recruitment.action; import zcib.recruitment.action.utils.UploadFile; import zcib.recruitment.domain.Student; import zcib.recruitment.service.StudentService; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFDataFormat; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.struts2.ServletActionContext; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.interceptor.ServletRequestAware; import com.opensymphony.xwork2.ActionSupport; public class AddStudentAction extends ActionSupport implements ServletRequestAware { private InputStream excelFile; private File uploadFile; private String uploadFileFileName; private StudentService studentService; private Student student; private String verifyCode; private HttpServletRequest request; // 进入页面查询数据 public String listAll() { HttpServletRequest request = ServletActionContext.getRequest(); List<Student> sList = studentService.findAll(); request.setAttribute("list", sList); return "listAll"; } // 导出Excel public String ExcelExport() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); String ids = request.getParameter("ids"); List<Student> list = new ArrayList<Student>(); String[] array = ids.split(","); int[] id = new int[array.length]; for (int i = 0; i < id.length; i++) { Student student = studentService .findById(Integer.valueOf(array[i])); list.add(student); } Workbook workbook = new HSSFWorkbook(); Sheet sheet = workbook.createSheet("学生信息"); Row row = sheet.createRow(0); row.createCell(0).setCellValue("考号"); row.createCell(1).setCellValue("姓名"); row.createCell(2).setCellValue("身份证号"); row.createCell(3).setCellValue("性别"); row.createCell(4).setCellValue("备注"); CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); for (int i = 1; i <= list.size(); i++) { Student stu = list.get(i - 1); row = sheet.createRow(i); row.createCell(0).setCellValue(stu.getExamId()); row.createCell(1).setCellValue(stu.getName()); row.createCell(2).setCellValue(stu.getMemberId()); row.createCell(3).setCellValue(stu.getSex()); row.createCell(4).setCellValue(stu.getRemark()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); workbook.write(baos); excelFile = new ByteArrayInputStream(baos.toByteArray()); baos.close(); return "excel"; } // 导入Excel public String ExcelInto() throws Exception { String directory = "/file"; String targetDirectory = ServletActionContext.getServletContext().getRealPath(directory); File target = UploadFile.Upload(uploadFile, uploadFileFileName,targetDirectory); List<Student> sList = new ArrayList<Student>(); excelFile = new FileInputStream(target); Workbook wb = new HSSFWorkbook(excelFile); Sheet sheet = wb.getSheetAt(0); int rowNum = sheet.getLastRowNum() + 1; for (int i = 1; i < rowNum; i++) { Student student = new Student(); Row row = sheet.getRow(i); int cellNum = row.getLastCellNum(); for (int j = 0; j < cellNum; j++) { Cell cell = row.getCell(j); String cellValue = null; switch (cell.getCellType()) { // 判断excel单元格内容的格式,并对其进行转换,以便插入数据库 case 0: cellValue = String .valueOf((int) cell.getNumericCellValue()); break; case 1: cellValue = cell.getStringCellValue(); break; case 2: cellValue = String .valueOf((int) cell.getNumericCellValue()); break; case 3: cellValue = cell.getStringCellValue(); break; case 4: cellValue = cell.getStringCellValue(); break; } switch (j) {// 通过列数来判断对应插如的字段 case 0: student.setExamId(cellValue); break; case 1: student.setName(cellValue); break; case 2: student.setMemberId(cellValue); break; case 3: student.setSex(Integer.valueOf(cellValue)); break; case 4: student.setRemark(cellValue); } } Student stu = studentService.findByExamId(student.getExamId());//判断数据库中是否拥有重复学生 if(stu==null){ sList.add(student); } } studentService.save(sList); return "success"; } public void setServletRequest(HttpServletRequest request) { this.request = request; } public Student getStudent() { return student; } public void setStudent(Student student) { this.student = student; } public String getVerifyCode() { return verifyCode; } public void setVerifyCode(String verifyCode) { this.verifyCode = verifyCode; } public StudentService getStudentService() { return studentService; } public void setStudentService(StudentService studentService) { this.studentService = studentService; } public InputStream getExcelFile() { return excelFile; } public void setExcelFile(InputStream excelFile) { this.excelFile = excelFile; } public File getUploadFile() { return uploadFile; } public void setUploadFile(File uploadFile) { this.uploadFile = uploadFile; } public String getUploadFileFileName() { return uploadFileFileName; } public void setUploadFileFileName(String uploadFileFileName) { this.uploadFileFileName = uploadFileFileName; } public HttpServletRequest getRequest() { return request; } public void setRequest(HttpServletRequest request) { this.request = request; } } ``` struts配置如下: ``` <action name="export_*" class="zcib.recruitment.action.AddStudentAction" method="{1}"> <result name="listAll">/recruitmentInfoList.jsp</result> <result name="success" type="redirect">export_listAll.action</result> <result name="excel" type="stream"> <param name="contentType">application/vnd.ms-excel</param> <param name="contentDisposition">attachment;filename="AllUsers.xls"</param> <param name="inputName">excelFile</param> </result> <result name="pdf" type="stream"> <param name="contentType">application/pdf; charset=gb2312</param> <param name="inputName">excelFile</param> <param name="contentDisposition">attachment; filename="contract.pdf"</param> <param name="bufferSize">2048</param> </result> <result name="word" type="redirect">export_listAll.action</result> </action> ``` 求大神帮忙看一下 内存溢出到底什么问题。
“阿飞哥”快来帮我看看这个hibernate得错误
<p>情况说明:</p> <p>      前台异步传入参数“speakId”,action获取speakId后(业务逻辑暂且在action中处理),到comment表中查找外键为speakId的comment们,保存在commList中,commList作为json类型返回前台(?)。</p> <p> </p> <p>ajax代码:</p> <pre name="code" class="html">... $.ajax({ type : "POST", url : "showComment.action", data : { speakId : speakId }, success : callbackShowComm, dataType : "json", error : function (data, status, e){ alert(e); history.go(0);} }); <pre name="code" class="html">//callbackShowComm function callbackShowComm(backData,status){  if(status == "success"){    if(backData != null){      //test      alert(backData);//此处没有返回值    }//end backData  }else{    alert(status);  } } </pre> <br><br>...</pre> <p> </p> <p>action代码:</p> <pre name="code" class="java">package com.shaiyaya.action; import java.util.*; import java.text.SimpleDateFormat; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import org.apache.struts2.interceptor.ServletRequestAware; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.Query; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; import com.shaiyaya.constant.ConstantVariable; import com.shaiyaya.dao.User; import com.shaiyaya.dao.Speak; import com.shaiyaya.dao.Comment; import com.shaiyaya.orm.HibernateSessionFactory; import com.shaiyaya.service.CommentService; public class CommentAction extends ActionSupport implements ServletRequestAware { private HttpServletRequest request; public void setServletRequest(HttpServletRequest request) { this.request = request; } private List&lt;Comment&gt; commList = new ArrayList&lt;Comment&gt;();//包含查看相应speakID对应的评论的Comment信息 public void setCommList(ArrayList&lt;Comment&gt; commList){ this.commList = commList; } public List&lt;Comment&gt; getCommList(){ return this.commList; } /** * 异步获取speakID对应的comment信息 * @return */ public String showComment(){ int speakId = Integer.valueOf( request.getParameter("speakId") ); if(speakId &lt;1){ return "errorSpeakId"; } Session session = HibernateSessionFactory.getSession(); Transaction tran = session.beginTransaction(); String sql = "from Comment as c where c.speak =" +speakId+ "order by commentId desc" ; Query query = session.createQuery(sql); commList = query.list();//说明:要是List commList = commentservice.findCommentBySpeakId(speakId);则没有报错了 // commList = commentservice.findCommentBySpeakId(speakId); tran.commit(); session.close(); request.setAttribute("commList", commList); System.out.println("commListSize:"+commList.size()); return "success"; } }//end class </pre> <p> </p> <p> </p> <p>struts-xml配置文件:</p> <pre name="code" class="xml"><span style="background-color: #ffffff;">... </span>&lt;package name="ajax-comment" extends="json-default"&gt; &lt;!-- 查看speak对应的评论异步请求 --&gt; &lt;action name="showComment" class="com.shaiyaya.action.CommentAction" method="showComment"&gt; &lt;result name="success" type="json"&gt; &lt;param name="root"&gt;commList&lt;/param&gt; &lt;/result&gt; &lt;result name="errorSpeakId" type="json"&gt; &lt;param name="root"&gt;commList&lt;/param&gt; &lt;/result&gt; &lt;/action&gt; &lt;/package&gt; ...</pre> <p> </p> <p>运行结果及报错:</p> <pre name="code" class="java">Hibernate: select comment0_.comment_id as comment1_23_, comment0_.speak_id as speak2_23_, comment0_.user_id as user3_23_, comment0_.content as content23_, comment0_.create_time as create5_23_ from shaiyaya.comment comment0_ where comment0_.speak_id=112 order by comment0_.comment_id desc Hibernate: select speak0_.speak_id as speak1_5_0_, speak0_.user_id as user2_5_0_, speak0_.content as content5_0_, speak0_.create_time as create4_5_0_, speak0_.last_comm_time as last5_5_0_, speak0_.cate_flag as cate6_5_0_, speak0_.attachment_flag as attachment7_5_0_, speak0_.comment_sum as comment8_5_0_, speak0_.love_sum as love9_5_0_, speak0_.forward_sum as forward10_5_0_ from shaiyaya.speak speak0_ where speak0_.speak_id=? Hibernate: select user0_.user_id as user1_15_0_, user0_.user_nick as user2_15_0_, user0_.real_name as real3_15_0_, user0_.password as password15_0_, user0_.user_ip as user5_15_0_, user0_.address as address15_0_, user0_.user_sex as user7_15_0_, user0_.create_time as create8_15_0_, user0_.update_time as update9_15_0_, user0_.user_email as user10_15_0_, user0_.user_intro as user11_15_0_, user0_.user_status as user12_15_0_, user0_.login_sum as login13_15_0_, user0_.last_login_time as last14_15_0_, user0_.role as role15_0_, user0_.memo as memo15_0_ from shaiyaya.user user0_ where user0_.user_id=? commListSize:2 [ERROR] 10-19-19:12:23 org.hibernate.LazyInitializationException.&lt;init&gt;(LazyInitializationException.java:19) [thread:http-80-2] [messgage:failed to lazily initialize a collection of role: com.shaiyaya.dao.Speak.comments, no session or session was closed] org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.shaiyaya.dao.Speak.comments, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentSet.equals(PersistentSet.java:350) at java.util.Vector.indexOf(Vector.java:361) at java.util.Vector.contains(Vector.java:320) at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:110) at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:324) at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:225) at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161) at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127) at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:324) at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:225) at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161) at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127) at com.googlecode.jsonplugin.JSONWriter.array(JSONWriter.java:416) at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:151) at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127) at com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:95) at com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:98) at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619)</pre> <p> </p> <p>前面action里面的commList = query.list改为List commList = commentservice.findCommentBySpeakId(speakId);则没有报错,不过这样就没有往前台传值了,ajax的success函数中的backData是没有值的。</p> <p>comment表有两个外键speakId和userId 在comment.hbm.xml已经设置了lazy=“false”,代码如下:</p> <pre name="code" class="xml">&lt;hibernate-mapping&gt; &lt;class name="com.shaiyaya.dao.Comment" table="comment" catalog="shaiyaya"&gt; &lt;id name="commentId" type="java.lang.Integer"&gt; &lt;column name="comment_id" /&gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;many-to-one name="speak" class="com.shaiyaya.dao.Speak" fetch="select" lazy="false"&gt; &lt;column name="speak_id" /&gt; &lt;/many-to-one&gt; &lt;many-to-one name="user" class="com.shaiyaya.dao.User" fetch="select" lazy="false"&gt; &lt;column name="user_id" /&gt; &lt;/many-to-one&gt; &lt;property name="content" type="java.lang.String"&gt; &lt;column name="content" /&gt; &lt;/property&gt; &lt;property name="createTime" type="java.util.Date"&gt; &lt;column name="create_time" length="19" /&gt; &lt;/property&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt;</pre> <p> </p> <p> </p> <p>这是什么原因呢?或者我要怎样才能把commList即comment对象的List传给前台呢?</p>
关于上传图片到服务器的路径问题!请大家帮一下忙
<p>在jsp页面上显示服务器的图片:</p> <pre name="code" class="html">&lt;img src="http://www.xxxx.com:serverPort/image/gfan.png" id="myImg" title="证件照(反面)" /&gt;</pre> <p> 这样显示是没有问题的。</p> <p>我在jsp页面上传图片到该服务器:</p> <pre name="code" class="java">&lt;form name="myform" action="upload!uploadfile" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" id="filePath" name="filePath"/&gt; &lt;input type="submit" id="mysubmit" value="上传"/&gt; &lt;/form&gt;</pre> <p> <span style="background-color: #ffffff;"> <span style="font-size: small;"><strong><span style="color: #0000ff;"> action:</span></strong></span></span></p> <pre name="code" class="java">package com.zhangying.util; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.Date; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.interceptor.ServletRequestAware; import org.apache.struts2.interceptor.ServletResponseAware; import com.opensymphony.xwork2.ActionSupport; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGEncodeParam; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class FileUpload extends ActionSupport implements ServletRequestAware,ServletResponseAware{ /** * author : Jacen * FileUpload Action * upload files from localhost to server */ private static final long serialVersionUID = 1L; private String filePath; private String serverPath; private HttpServletResponse response; private HttpServletRequest request; public String uploadfile() throws Exception { System.out.println(filePath); //参数1:本地文件路径 // System.out.println(serverPath); //参数2:要上传的服务器路径 String resultPath = ""; // 上传后图片所在的路径 FileOutputStream out = null; // 文件输出流 try { // 验证图片上传的格式是否正确 File f = new File(filePath); if (!f.isFile()) { throw new Exception(" f不是图片文件!"); } if (f != null &amp;&amp; f.exists()) { // 这里的ImageIO属于java工厂类,在工厂类class里面,调用的System.gc(),频繁调用会造成dump,需要考虑优化 BufferedImage image = ImageIO.read(f); // 读入文件 if (image != null) { BufferedImage tag = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB); // 构造一个类型为预定义图像类型之一的 BufferedImage tag.getGraphics().drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null); // 绘制所需要尺寸大小的图片 /* * 以下生成 图片上传后在服务器上的 新路径 */ int lastLength = filePath.lastIndexOf("."); String imageName="jacen"; //用用户名来作为上传图片的文件名 String fileType = filePath.substring(lastLength); // 获取上传图片的类型 resultPath = "http://www.gyswad.com:90/developerCerpic/"+ imageName+ fileType; //图片在服务器上的地址 System.out.println(resultPath); /* * 进行图片的绘制 */ out = new FileOutputStream(resultPath); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam param = encoder .getDefaultJPEGEncodeParam(tag); param.setQuality(0.95f, true); // 95%图像 param.setDensityUnit(1); // 像素尺寸单位.像素/英寸 param.setXDensity(300); // 水平分辨率 param.setYDensity(300); // 垂直分辨率 encoder.setJPEGEncodeParam(param); encoder.encode(tag); tag = null; } } f = null; } catch (Exception e) { e.printStackTrace(); }finally{ out.close(); out=null; } // request.setAttribute("resultPath", resultPath); // return resultPath; return "success"; } public String getFilePath() { return filePath; } public void setFilePath(String filePath) { this.filePath = filePath; } public String getServerPath() { return serverPath; } public void setServerPath(String serverPath) { this.serverPath = serverPath; } public HttpServletResponse getResponse() { return response; } public void setResponse(HttpServletResponse response) { this.response = response; } public HttpServletRequest getRequest() { return request; } public void setRequest(HttpServletRequest request) { this.request = request; } @Override public void setServletResponse(HttpServletResponse arg0) { // TODO Auto-generated method stub } @Override public void setServletRequest(HttpServletRequest arg0) { // TODO Auto-generated method stub } }</pre> <p>  <span style="color: #ff0000;">现在报错:说是空指向异常</span></p> <pre name="code" class="java">finally{ out.close(); out=null; }</pre> <p>我感觉是resultPath&lt;!--上传图片到服务器的路径--&gt;有问题,请各位帮忙看一下,这里的resultPath到底怎么写?<span style="color: #ff0000; font-size: small;"><strong>还有,如果各位还有什么更好的方法实现图片上传,请指教。本人新手,一切都略知。</strong></span></p> <p>控制台打印的错误信息是这样的:</p> <pre name="code" class="java">\temp\upload__daca63c_1399f88364d__8000_00000000.tmp http://www.gyswad.com:90/developerCerpic/jacen.tmp java.io.FileNotFoundException: http:\www.gyswad.com:90\developerCerpic\jacen.tmp (文件名、目录名或卷标语法不正确。) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.&lt;init&gt;(Unknown Source) at java.io.FileOutputStream.&lt;init&gt;(Unknown Source) at com.zhangying.util.FileUpload.uploadfile(FileUpload.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)</pre> <p> <span style="color: #800080;"><em><strong>补充:我想将本地图片上传到服务器的d://Apache2.2/temp/image文件夹下面。</strong></em></span></p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p>
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
【资源】一个C/C++开发工程师的学习路线(已经无路可退,唯有逆风飞翔)【内附资源页】
声明: 1)该文章整理自网上的大牛和专家无私奉献的资料,具体引用的资料请看参考文献。 2)本文仅供学术交流,非商用。所以每一部分具体的参考资料并没有详细对应。如果某部分不小心侵犯了大家的利益,还望海涵,并联系博主删除。 3)博主才疏学浅,文中如有不当之处,请各位指出,共同进步,谢谢。 4)此属于第一版本,若有错误,还需继续修正与增删。还望大家多多指点。大家都共享一点点,一起为祖国科研的推进...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
20道你必须要背会的微服务面试题,面试一定会被问到
写在前面: 在学习springcloud之前大家一定要先了解下,常见的面试题有那块,然后我们带着问题去学习这个微服务技术,那么就会更加理解springcloud技术。如果你已经学了springcloud,那么在准备面试的时候,一定要看看看这些面试题。 文章目录1、什么是微服务?2、微服务之间是如何通讯的?3、springcloud 与dubbo有哪些区别?4、请谈谈对SpringBoot 和S...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
神级宝库!GitHub 标星 1.2w+,Chrome 最天秀的插件都在这里啦!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个沉迷 Chrome 不能自拔的蒟蒻… 作为一个在远古时代用过什么 IE、360、猎豹等浏览器的资深器哥,当我第一次了解 Chrome 的时候,就被它的美貌给吸引住了… 就在我用了一段时间之后,我坚决的卸载了电脑上其它碍眼的浏览器,并觉得在之前的搬砖生涯中,我不配当哥,我只配是个沙雕… ...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
张朝阳回应迟到 1 分钟罚 500:资本家就得剥削员工
loonggg读完需要2分钟速读仅需 1 分钟大家我,我是你们的校长。前几天,搜狐的董事局主席兼 CEO 张朝阳和搜狐都上热搜了。原因很简单,就是搜狐出了“考勤新规”。一封搜狐对员工发布...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
立即提问