1, 开始是用注解对service进行配置,后来干脆把xml的配置一起加进去了,还是没注入,不知道什么原因。
@Autowired
private UserRegisterService userRegisterService;
<bean name="userRegisterService" class="com.zb.service.impl.UserRegisterServiceImpl">
<property name="userDao" ref="userDaoImpl"></property>
</bean>
if(this.userRegisterService == null){
System.out.println("service为空,没有注入");
}
还是为null
把struts2-struts1-plugin-2.3.1.jar加进去后,在struts.xml文件中配置:
<constant name="struts.objectFactory" value="spring" />
报错:
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:102)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:747)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1214)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:673)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:455)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:485)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:138)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:142)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:53)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:604)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:535)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:398)
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:332)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:118)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:546)
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:221)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:43)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:53)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:91)
at org.eclipse.jetty.server.Server.doStart(Server.java:261)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1203)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:469)
at org.eclipse.jetty.start.Main.start(Main.java:612)
at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
at org.eclipse.jetty.start.Main.main(Main.java:79)
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:295)
at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:266)
at org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:202)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 44 more
把工程从服务器中remove,在加入,重启,错误消失
2,对自定义的action在测试时,set一个request,但是action的那些属性不能马上有值。
this.request = new MockHttpServletRequest();
this.response = new MockHttpServletResponse();
this.request.setAttribute("email", "a");
this.request.setAttribute("password", "a");
this.request.setAttribute("password2", "a");
this.request.setAttribute("birthday", "2011-11-11");
this.request.setAttribute("gender", "1");
this.request.setAttribute("realName", "a");
this.regAction.setRequest(request);
assertNotNull(this.regAction.getBirthday());
最后还是为null
3,struts的namespace问题
There is no Action mapped for namespace [/] and action name [register] associated with context path [/kechengsheji].
这个问题,真的没法解释,action换个名字居然就好了!把register换成testRegister。
太假了!到底是为什么?
解决:
<form method="post" action="register.action" name="regform" id="regform">
<?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> <package name="register" extends="struts-default" namespace="/"> <action name="register" class="com.zb.action.RegisterAction" method="register"> <result name="success">/index.jsp</result> <result name="error">/registe.jsp</result> </action> </package> </struts>
但是我明明记得之前也是这么配置的,这么会抽风一样的不行呢?我现在觉得应该浏览器里有缓存, 可是我每次都重启服务器,想不通
4,IE不完全显示
我用了其他浏览器,chrome、Firefox都能显示,而且图片显示很快,怎到了IE就总是少这少那!
5,tomcat内存不足
安装的时候是用.exe文件安装,没有用解压式的安装,导致现在要配置比较困难
6,jetty问题
前几天,看到装了jetty7.6,启动的时间确实比tomcat快,也没出现tomcat的内存问题,但是在页面加载方面好像有些欠缺