运行的日志2013-7-28 18:54:51 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: E:\myexslipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin;E:\myexslipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin
2013-7-28 18:54:51 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-7-28 18:54:51 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 305 ms
2013-7-28 18:54:51 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-7-28 18:54:51 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
2013-7-28 18:54:52 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2013-7-28 18:54:56 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts-default.xml]
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts-plugin.xml]
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts.xml]
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.ObjectFactory)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.FileManagerFactory)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.XWorkConverter)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.CollectionConverter)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.ArrayConverter)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.DateConverter)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.NumberConverter)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.StringConverter)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionFileProcessor)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.TypeConverterCreator)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.TypeConverterHolder)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.TextProvider)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.LocaleProvider)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.ActionProxyFactory)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ObjectTypeDeterminer)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (org.apache.struts2.dispatcher.mapper.ActionMapper)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (jakarta) for (org.apache.struts2.dispatcher.multipart.MultiPartRequest)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (org.apache.struts2.views.freeer.FreeerManager)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (org.apache.struts2.components.UrlRenderer)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.validator.ActionValidatorManager)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.ValueStackFactory)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionProvider)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionContextFactory)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.PatternMatcher)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (org.apache.struts2.dispatcher.StaticContentLoader)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.UnknownHandlerManager)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (org.apache.struts2.views.util.UrlHelper)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.TextParser)
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Overriding property struts.i18n.reload - old value: false new value: true
2013-7-28 18:54:57 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Overriding property struts.configuration.xml.reload - old value: false new value: true
2013-7-28 18:54:57 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2013-7-28 18:55:00 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-7-28 18:55:00 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-7-28 18:55:00 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/18  config=null
2013-7-28 18:55:00 org.apache.catalina.startup.Catalina start
信息: Server startup in 8863 ms
程序是:package com.test.action;import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;import com.opensymphony.xwork2.ActionSupport;
import com.test.model.User;
import com.test.service.UserService;@Component("login")
@Scope("prototype")
public class LoginAction extends ActionSupport {
private String name;

public String execute(){
System.out.println(name);
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
UserService service = (UserService)applicationContext.getBean("userService");
User u = new User();
u.setName(name);
service.addUser(u);
return "success";
}
public String getName() {
return name;
} public void setName(String name) {
this.name = name;
}
}我加了一个输出,结果是null。请问下这是怎么回事啊,如果不整合spring是可以的

解决方案 »

  1.   

    解决方法:
    web.xml添加监听器
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>applicationContext.xml,spring管理struts的bean写上:scope="request"
    看起来像
    <bean id="adminConfigAction" class="caobug.ConfigAction" scope="request">
    <property name="sysConfigService" ref="systemConfigService"></property>
    </bean>
      

  2.   

    HttpServletRequest request=(HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST);
    String a=request.getParameter("userName");可以直接去到get的参数吧
      

  3.   

    额,好像还是不行呢,下面是我的原码 100多K麻烦看下,谢谢http://url.cn/GrYEVb
      

  4.   


    谢谢回复,但是这样不就没有有到struts吗?我是初学者呢,想弄清楚ssh的构架。
      

  5.   

    呵呵,我也是刚学ssh的。
    import org.apache.struts2.ServletActionContext;
    import com.opensymphony.xwork2.ActionContext;
    从导入的包看出,request是通过struts处理的。我查了一下,这篇写的不错,参考一下:
    http://boxipo.blog.163.com/blog/static/7580975320089269351715/