我有一个String列表,我将其设置为一个会话:
session.setAttribute("datas", result.getBody().getDatas());
Run Code Online (Sandbox Code Playgroud)
然后我想检查JSP,如果在datas属性中没有包含单词"apple",例如.如果未包含,则打印不包含的消息.最初我试图做这样的事情:
<c:forEach items="${datas}" var="data">
<c:if test="${data!='apple'}">
<p> Doesn't contained</p>
</c:if>
<c:for>
Run Code Online (Sandbox Code Playgroud)
但是前面提到的代码,如果会话包含以下值:
苹果香蕉柠檬
打印两次"不包含"消息.我知道这是正常的,但我怎么能对待这个以达到我想要的呢?
我在休息Web服务中多次看到xml,具有以下格式:
<author>
<atom:link rel="author" type="application/xml" href="http://www.../author/1"/>
</author>
Run Code Online (Sandbox Code Playgroud)
并且网址(http://www.../author/1)将包含以下内容:
<author xmlns="http://www.../ckp" xmlns:atom="http://www.w3.org/2005/atom">
<name>S. Crocker</name>
<address>None</address>
<affiliation></affiliation>
<email>None</email>
</author>
Run Code Online (Sandbox Code Playgroud)
我正在尝试解组以下xml:
<datas xmlns="http://www..." xmlns:atom="http://www.w3.org/2005/atom">
<data>
<atom:link rel="data" type="application/xml" href="http://www.../ckp/data/1"/>
</data>
<data>
<atom:link rel="data" type="application/xml" href="http://www.../ckp/data/2"/>
</data>
<data>
<atom:link rel="data" type="application/xml" href="http://www.../ckp/data/3"/>
</data>
</datas>
Run Code Online (Sandbox Code Playgroud)
我编写了以下绑定类来帮助实现编组/解组:
public class Links{
@XmlAttribute
private String rel;
@XmlAttribute
private String type;
@XmlAttribute
private String href;
public String getRel() {
return rel;
}
public void setRel(String rel) {
this.rel = rel;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getHref() {
return href;
}
public void …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
protected <T> T getValueForKey(String key) {
T value = null;
// currentStats is just a Bundle
if (currentStats.containsKey(key)) {
return value;
}
return value;
}
Run Code Online (Sandbox Code Playgroud)
我该如何设置限制?例如,T是String或int或double.这可能吗?
PS
我不想用
protected <T extends String> T getValueForKey(String key) {
}
Run Code Online (Sandbox Code Playgroud)
因为我不想只有弦乐..
Bundle bundle;
//set data to bundle
//......
File file = new File(context.getFilesDir().getAbsolutePath() + "/data/");
FileOutputStream fos;
try {
fos = new FileOutputStream(file);
//fos.write
fos.close();
} catch (FileNotFoundException exp1) {
exp1.printStackTrace();
} catch ( IOException exp2) {
exp2.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我有上述代码.我想要做的就是将捆绑包保存到文件中.我发现方法写了但是我不能传递一个包但只传递一个byte [].我试图将bundle转换为byte []但是我没有成功.我该怎么做才能做到这一点?什么是最有效的方式?
我正在向服务器发送数据,我想收到HTTP响应状态,以检查此状态并提供适当的视图
@RequestMapping(method = RequestMethod.POST)
public String Login(@ModelAttribute("Attribute") Login login, Model model,HttpServletRequest request) {
// Prepare acceptable media type
ArrayList<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
acceptableMediaTypes.add(MediaType.APPLICATION_XML);
// Prepare header
HttpHeaders headers = new HttpHeaders();
headers.setAccept(acceptableMediaTypes);
HttpEntity<Login> entity = new HttpEntity<Login>(login, headers);
// Send the request as POST
try {
ResponseEntity<Login> result = restTemplate.exchange("http://www.../user/login/",
HttpMethod.POST, entity, Login.class);
} catch (Exception e) {
}
//here i want to check the received status
if(status=="OK"){
return "login"
}
else
return "redirect:/home";
}
Run Code Online (Sandbox Code Playgroud) 我的网址总是以数字结尾,例如:
String url = "localhost:8080/myproject/reader/add/1/";
String anotherurl = "localhost:8080/myproject/actor/take/154/";
Run Code Online (Sandbox Code Playgroud)
我想提取最后两个斜杠("/")之间的数字.
有谁知道我怎么做到这一点?
我正在尝试登录。我正在使用 Spring MVC 框架。我必须实现一个表单,在服务器上提交密码和用户名。我的表格如下:
该模型:
package org.client.log;
import javax.xml.bind.annotation.*;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class InfoLogin{
private String username;
private String password;
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我使用 jaxb 技术对与服务器端交换的 xml 进行编组和解组。问题是我需要使用 base64 编码对用户名和密码进行编码,然后将其发送到服务器端。编码应该在标题上添加一些东西。我阅读了很多教程,其中大部分都说我应该使用 spring 安全性。我不知道该怎么做。有没有人有什么建议?
实际上,我想做的是:对此(“用户名:密码”)进行 base64 编码并创建此“QWxh784bjpvcG58VuIHNlc2FtZQ==”(例如),它将添加到标题中
我想创建一个网站,有时我得到了PermGen例外.
所以我开始寻找减少创建对象数量的方法,并减少内存消耗.
我看了一些文章.但我不确定一些事情.
例如,在方法(全局)之外声明列表或在方法中创建列表是否更好?在这种情况下,内存消耗方面的差异是什么?如果我将它们声明为本地,这意味着在使用它们后,垃圾收集器将收集它们,从而释放堆中的空间?
任何人都可以提出减少更多内存消耗和减少创建对象数量的方法(@Autowired是一种更好的方式来声明对象)吗?
我正在尝试创建一个字符串,我希望这个形式是exaclty:
<atom:link rel="name" type="html" href="http://www/data/name/1"/>
Run Code Online (Sandbox Code Playgroud)
我正在尝试这个:
String astring = "<atom:link rel="+"name"+" "+"type="+"html"+" "+"href="+"http://www/data/name/"+id+"/>"
Run Code Online (Sandbox Code Playgroud)
我接受这个:
<atom:link rel=name type=html href=http://www/data/name/1/>
Run Code Online (Sandbox Code Playgroud)
有关于此的任何想法?
我试图理解当某人将一个特定类的对象转换为另一个类时发生的事情.即有两个类
public class Aclass{
private String attribute1;
private List<String> attribute2;
//get/set methods
}
public class Bclass{
private String attribute1;
private List<int> attribute2;
//get/set methods
}
Run Code Online (Sandbox Code Playgroud)
现在在另一个类中,我有这两个对象,然后我投射它们.
public class Cclass{
Aclass aclass=new Aclass();
//returneddata is a method that returns an Aclass object that contained dta for the Aclass attributes
aclass=returneddata();
Bclass bclass=new Bclass();
bclass=Bclass.class.cast(aclass);
}
Run Code Online (Sandbox Code Playgroud)
从前面提到的类我采取了java.lang.ClassCastException.
问题是我有两个类,每个类只包含两个属性但每个都包含它们.这些属性中的16个在两个类中都是通用的.
此外,returneddata方法返回从存储库中检索的对象.您可以理解我想找到一种方法并将对象Aclass的16个数据属性传递给对象Bclass.
我想要:
1)找到一种方法将16个公共属性数据从一个对象重写到另一个对象
2)演员如何运作一般
任何命题?
我尝试实现SHA1解码器,但我在互联网上找不到有用的东西.任何人都可以帮我找到有关如何实现SHA1解密的信息.我想将加密数据转换为字符串.
java ×10
jaxb ×2
spring-mvc ×2
android ×1
annotations ×1
atom-feed ×1
casting ×1
cryptography ×1
el ×1
encoding ×1
encryption ×1
generics ×1
http-headers ×1
inheritance ×1
jsp ×1
jstl ×1
oop ×1
rest ×1
sha1 ×1
string ×1