难道一类将作为一个Spring应用程序的Bean同时需要@Component和@Named在同一时间?
如果两者都这样使用有什么意义?
我尝试搜索网络,并看到这些注释的标准文档,发现它们有点令人困惑.
最后,如果@Named注释没有为bean指定任何名称,应用程序将采用哪个名称?
我在bash上尝试了以下命令
echo this || echo that && echo other
Run Code Online (Sandbox Code Playgroud)
这给出了输出
this
other
Run Code Online (Sandbox Code Playgroud)
我不明白!
我的干跑是这样的:
echo this || echo that && echo other 暗示 true || true && true&&具有more precedence比||,所述第二表达式计算第一both are true,在||评价这也给了真.那
其他
这个
从&&具有更多优先级的Java背景来看||,我无法将其与bash联系起来.
任何输入都会非常有用!
有pom.xml和web.xml的Java项目有什么区别?项目可以同时具有这两种配置吗?
我正在开发一个Web服务.我想将401: Unauthorized响应返回给用户以获取无效凭据.
如何手动返回此响应代码?
我只想在Gmail应用中实现与弹出菜单相同的功能,并固定在右上角的溢出按钮上.为此,我使用与Android Android弹出菜单的谷歌教程相同的代码,但对于我显示弹出菜单在动作栏的边缘不在那之下.如果你在gmail溢出的pop菜单上注意到你看到popmenu发生在actionbar的边缘.
这是我用于弹出菜单的xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/item1"
android:title="lablab"/>
<item
android:id="@+id/item2"
android:title="lablab"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
以下是我的活动:
public void showFontSetting(View view) {
PopupMenu popup = new PopupMenu(this, view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.menu, popup.getMenu());
popup.show();
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.item1:
Toast.makeText(Index.this,
"You Clicked : " + item.getTitle(),
Toast.LENGTH_SHORT).show();
break;
case R.id.item2:
break;
}
return true;
}
});
}
Run Code Online (Sandbox Code Playgroud) 我在本地计算机上运行了Tomcat 6实例.
我在其配置中进行了以下更改:
在/ conf/context.xml- 更改标签如下
<Context crossContext="true">
Run Code Online (Sandbox Code Playgroud)在/ conf/server.xml - 更改标签如下
<Connector port="8080" protocol="HTTP/1.1" emptySessionPath="true"
connectionTimeout="20000"
redirectPort="8443" />
Run Code Online (Sandbox Code Playgroud)假设我有一个名为SampleProject.wardeploy 的WAR文件,它提取到文件夹SampleProject.
在这个WAR中的一些servlet中,比方说SampleServlet,我写了两段代码,如下所示:
ServletContext context1 = session.getServletContext();
Run Code Online (Sandbox Code Playgroud)
和
ServletContext context2 = session.getServletContext().getContext("/SampleProject");
Run Code Online (Sandbox Code Playgroud)
context1和之间有什么区别context2?我认为两者都是指应用程序上下文.但是,如果我设置了一些属性context1并访问context2,我没有得到的价值context2.
任何帮助,将不胜感激.
我想在这里实现的是由子类决定是否要将java.lang.String或java.util.HashMap作为参数传递给query()方法.接口只需要声明子类必须实现查询方法,但我不关心什么类型的参数子类想要传入.
我有一个界面,如:
interface A<T>{
public void query(T type);
}
Run Code Online (Sandbox Code Playgroud)
两个子类如:
public class B implements A<String> {
public void query(String type);
}
public class C implements A<HashMap> {
public void query(HashMap type);
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个工厂类来生产B或C:
public class AFactory {
public static A<?> getType(String type) {
if(type.equals("B")){
return new B();
} else if(type.equals("C")) {
return new C();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这个想法是客户端可以使用如下的接口,而不依赖于B,C,如:
A instance = AFactory.getType("B");
String a = "test";
instance.query(a);
Run Code Online (Sandbox Code Playgroud)
我在这里遇到的问题是:eclipse在instance.query(a)行上给出了错误:
类型A中的方法查询(捕获#2-of?)不适用于参数(String).
我认为问题是接口契约不知道查询应该期待String或HashMap.我只能想到解决这个问题的方法是,我必须将结果转换为:
B instance = (B)AFactory.getType("B");
String a = "test";
instance.query(a); …Run Code Online (Sandbox Code Playgroud) 我知道J2EE可以用于JSP + Servlets.但是,我可以将J2SE用于JSP和Servlets吗?
在处理我的代码时,我使用了它Collections并且遇到了对我来说非常奇怪的东西.我想知道为什么之前从未问过这个问题,尽管我所指的这个类和方法来自Java 1.4
/**
* Returns an array list containing the elements returned by the
* specified enumeration in the order they are returned by the
* enumeration. This method provides interoperability between
* legacy APIs that return enumerations and new APIs that require
* collections.
*
* @param e enumeration providing elements for the returned
* array list
* @return an array list containing the elements returned
* by the specified enumeration.
* @since 1.4
* @see …Run Code Online (Sandbox Code Playgroud) java ×7
java-ee ×2
android ×1
android-menu ×1
annotations ×1
bash ×1
collections ×1
generics ×1
inheritance ×1
interface ×1
linux ×1
popup ×1
servlets ×1
shell ×1
soap ×1
spring ×1
tomcat ×1
web-services ×1