为了解决这个问题,我搜索了高低,但我找不到解决方案.问题如下:我在Tomcat 7服务器上有一个Spring-mvc webapp构建 - 确切地说是7.0.12 - 而且我无法使<mvc:resources>标记正常工作.正如您将在下面看到<mvc:resources>的旧资源文件夹的工作,但我更喜欢在/WEB-INF/web/目录中有资源文件夹.
MediorkoorVOICES的Web-servlet.xml中:
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.oudejans.mediorkoorvoices.web" />
<mvc:resources mapping="/resources/**" location="/WEB-INF/web/resources/" />
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/web/jsp/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean>
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<import resource="web/tiles/web-tiles.xml" />
</beans>
Run Code Online (Sandbox Code Playgroud)
文件夹结构:
META-INF
resources (Old resources folder)
- web
- images
- css
- main.css
WEB-INF …Run Code Online (Sandbox Code Playgroud) 我目前正在研究API控制器.该控制器应该能够捕获任何 - 未知 - 参数并将其放入Map对象中.现在我正在使用此代码来捕获所有参数并将它们放入Map
public String processGetRequest(final @RequestParam Map params)
Run Code Online (Sandbox Code Playgroud)
现在我打电话的网址如下:
server/api.json?action=doSaveDeck&Card_IDS[]=1&Card_IDS[]=2&Card_IDS[]=3
Run Code Online (Sandbox Code Playgroud)
然后我用这段代码打印出参数,用于调试目的:
if (logger.isDebugEnabled()) {
for (Object objKey : params.keySet()) {
logger.debug(objKey.toString() + ": " + params.get(objKey));
}
}
Run Code Online (Sandbox Code Playgroud)
结果是:
10:43:01,224 DEBUG ApiRequests:79 - action: doSaveDeck
10:43:01,226 DEBUG ApiRequests:79 - Card_IDS[]: 1
Run Code Online (Sandbox Code Playgroud)
但预期的结果应该是这样的:
10:43:XX DEBUG ApiRequests:79 - action: doSaveDeck
10:43:XX DEBUG ApiRequests:79 - Card_IDS[]: 1
10:43:XX DEBUG ApiRequests:79 - Card_IDS[]: 2
10:43:XX DEBUG ApiRequests:79 - Card_IDS[]: 3
Run Code Online (Sandbox Code Playgroud)
或至少告诉我Card_IDS是一个String[] / List<String>,因此应该铸造.我也尝试将参数List<String>手动转换为手动但不起作用:
for …Run Code Online (Sandbox Code Playgroud) 有时我需要在我的测试用例中嘲笑相当长的时间来写出POJO.我想知道无论如何我都可以在Intellij(14)中从调试变量数据生成模拟?
作为一个例子,我们有一个类:
public class MyClass{
private String aVariableWithARatherLongName1;
private Double aVariableWithARatherLongName2;
private String aVariableWithARatherLongName3;
private Long aVariableWithARatherLongName4;
private String aVariableWithARatherLongName5;
private Boolean aVariableWithARatherLongName6;
private String aVariableWithARatherLongName7;
private String aVariableWithARatherLongName8;
private String aVariableWithARatherLongName9;
private String aVariableWithARatherLongName10;
private String aVariableWithARatherLongName11;
private String aVariableWithARatherLongName12;
//getters & setters
}
Run Code Online (Sandbox Code Playgroud)
在我的调试变量视图中,我将有一个MyClass变量列表:
- myClasses = {ArrayList@0} size = 5
- 0 = {MyClass@1}
- aVariableWithARatherLongName1 = {String} "value 1"
- aVariableWithARatherLongName2 = {Double} 2.0
- aVariableWithARatherLongName3 = {String} "value 1"
...
- 1 = …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个需要NFC集成的Android项目.现在,我想编写一些(j)单元测试,以查看应用程序是否可以接收NFC意图(特别是ACTION_TECH_DISCOVERED)并将给定标记(in NfcAdapter.EXTRA_TAG)放在总线系统上.但令我惊讶的是,我无法创建Tag实例或模拟实例.有人可以向我解释我是如何(单位)测试的吗?
此时我甚至会接受一种集成测试,其过程如下:
Tag对象CardDetectedEvent.我有一部支持NFC的手机和一些用于测试的卡.
Android SDK版本:19
使用的库:robolectric,junit和mockito
我正在尝试创建以下场景:
public interface DaggerInjectionFactory {
void inject(MyActivity myActivity);
}
@Singleton
@Component(modules = {RestModule.class})
public interface MyRestComponent extends DaggerInjectionFactory {
RestClient provideRestClient();
}
@Singleton
@Component(modules = {PreferencesModule.class})
public interface MyPreferencesComponent extends DaggerInjectionFactory {
SharedPreferences provideSharedPreferences();
}
Run Code Online (Sandbox Code Playgroud)
匕首编译器给了我以下错误作为响应:
error: RestClient cannot be provided without an @Provides- or @Produces-annotated method.
Run Code Online (Sandbox Code Playgroud)
该RestModule包含一个@Provides @Singleton RestClient provideRestClient()方法,它也是值得一提的是,当我删除了extends DaggerInjectionFactory从MyPreferencesComponent匕首编译器生成组件制造商没有问题。
我想要做的是创建一个包含所有可注入类的接口,我想在其中使用@Inject注释,并在我的“所有”组件中实现它们,这样我就不必将其添加void inject(MyActivity myActivity);到我的所有组件中.
因为我是该框架的新手,所以我不知道正确的术语是什么,因此对于我需要搜索的内容没有真正的线索。
所以我的问题是:是否有可能创建这样一个结构,定义一个接口来自动将所有void inject()方法添加到我的“所有”组件中?如果是这样,怎么办?
-- 编辑 -- 预期的用法类似于:
public MyActivity extends Activity …Run Code Online (Sandbox Code Playgroud)