我想要GrantedAuthorityImpl()类的替代方法.我希望在spring安全实现中使用它.GrantedAuthorityImpl()类是Depricated.hence我想要它的替代解决方案.
我的代码:
public Collection<GrantedAuthority> getAuthorities(Integer access) {
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>(2);
if (access.compareTo(1) == 0) {
authList.add(new GrantedAuthorityImpl("ROLE_ADMIN"));
}
else{
authList.add(new GrantedAuthorityImpl("ROLE_USER"));
}
return authList;
}
Run Code Online (Sandbox Code Playgroud) 查看W3 Schools URL编码网页,它表示@应该编码为%40,并且space应编码为%20.
我都试过URLEncoder和URI,但同样没有上面的正确:
import java.net.URI;
import java.net.URLEncoder;
public class Test {
public static void main(String[] args) throws Exception {
// Prints me%40home.com (CORRECT)
System.out.println(URLEncoder.encode("me@home.com", "UTF-8"));
// Prints Email+Address (WRONG: Should be Email%20Address)
System.out.println(URLEncoder.encode("Email Address", "UTF-8"));
// http://www.home.com/test?Email%20Address=me@home.com
// (WRONG: it has not encoded the @ in the email address)
URI uri = new URI("http", "www.home.com", "/test", "Email Address=me@home.com", null);
System.out.println(uri.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,URLEncoder电子邮件地址是否正确但不是空格,并且 …
在最近添加支持后,我试图通过iOS11上的Safari上的麦克风进行音频捕获
但是,onaudioprocess永远不会调用回调.这是一个示例页面:
<html>
<body>
<button onclick="doIt()">DoIt</button>
<ul id="logMessages">
</ul>
<script>
function debug(msg) {
if (typeof msg !== 'undefined') {
var logList = document.getElementById('logMessages');
var newLogItem = document.createElement('li');
if (typeof msg === 'function') {
msg = Function.prototype.toString(msg);
} else if (typeof msg !== 'string') {
msg = JSON.stringify(msg);
}
var newLogText = document.createTextNode(msg);
newLogItem.appendChild(newLogText);
logList.appendChild(newLogItem);
}
}
function doIt() {
var handleSuccess = function (stream) {
var context = new AudioContext();
var input = context.createMediaStreamSource(stream)
var processor = …Run Code Online (Sandbox Code Playgroud) spring有两种方法可以使用propertiesfactorybean或propertyplaceholderconfigurer加载属性文件.
你可以解释一下它们之间的区别以及何时使用它们?
谢谢!
在我的java/spring应用程序中,我有一个速度模板,我在其中创建一个地图,该地图将保存也插入模板中的值:
#set ($myMap = {})
Run Code Online (Sandbox Code Playgroud)
我想要做的是如果地图为空则检查if/else.这对我来说似乎没有用.我试过了:
#if ($myMap.empty)
...
#if ($myMap.size == 0)
Run Code Online (Sandbox Code Playgroud)
这些都不奏效.检查Map的速度是否为空的正确方法是什么.我试过搜索文档和SO,但我找不到一个例子.
我遇到了Spring和post请求的问题.我正在为Ajax调用设置一个控制器方法,请参阅下面的方法定义
@RequestMapping(value = "add.page", method = RequestMethod.POST)
@ResponseBody
public Object createComment(
@RequestParam(value = "uuid", required = false) String entityUuid,
@RequestParam(value = "type", required = false) String entityType,
@RequestParam(value = "text", required = false) String text,
HttpServletResponse response) {
....
Run Code Online (Sandbox Code Playgroud)
无论我以何种方式进行HTML调用,@RequestParam参数的值始终为null.我有很多其他方法看起来像这样,主要区别在于其他方法是GET方法,而这一方法是POST.是不是可以使用@RequestParamPOST方法?
我正在使用Spring版本3.0.7.RELEASE - 有谁知道问题的原因可能是什么?
Ajax代码:
$.ajax({
type:'POST',
url:"/comments/add.page",
data:{
uuid:"${param.uuid}",
type:"${param.type}",
text:text
},
success:function (data) {
//
}
});
Run Code Online (Sandbox Code Playgroud) 可以使用jar如下命令更新 JAR 文件中的单个文件:
jar uf TicTacToe.jar images/new.gif
Run Code Online (Sandbox Code Playgroud)
有没有办法以编程方式做到这一点?
如果我使用JarOutputStream,我必须重写整个 jar 文件,所以我想知道是否有类似的“随机访问”方式来做到这一点。鉴于它可以使用该jar工具完成,我曾期望有一种类似的方式以编程方式完成。
我已经设置了我的spring-mvc servlet以匹配*.page请求.我已将web.xml中的welcome-file-list设置为index.page
当我转到我的网络服务器的根目录时,这会有效:
http://me.com确实会被正确地重定向到http://me.com/index.page.
但是,当我使用子目录时,它不会重定向:
http://me.com/dashboard并没有重定向到http://me.com/dashboard/index.page
有没有办法让这个映射工作?
我的web.xml文件(摘录):
<welcome-file-list>
<welcome-file>index.page</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>*.page</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
我的webdefault.xml(来自码头):
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>welcomeServlets</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>redirectWelcome</param-name>
<param-value>false</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud) 我目前正在使用Jawr来压缩和捆绑我的 css、javascript 和图像文件。
Jawr目前正在转换我的 css 文件中的所有 url() 链接,无论它们是否是图像。例如:
@font-face {
font-family: 'NothingYouCouldSay';
src: url('../fonts/NothingYouCouldSay.eot') format('eot');
src: local("?"), url('../fonts/NothingYouCouldSay.woff') format('woff'), url("../fonts/NothingYouCouldSay.otf") format("opentype"), url('../fonts/NothingYouCouldSay.ttf') format('truetype'), url('../fonts/NothingYouCouldSay.svg') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
Jawr 正在转换所有 url() 值,但是当网络服务器运行时无法找到资源,因为我已将图像 servlet 配置为仅侦听 *.png 和 *.jpg。
@font-face {
font-family: 'NothingYouCouldSay';
src: url('../../../cb1130234589/resources/fonts/NothingYouCouldSay.eot') format('eot');
src: local("?"), url('../../../cb1130234589/resources/fonts/NothingYouCouldSay.woff') format('woff'), url("../../../cb1130234589/resources/fonts/NothingYouCouldSay.otf") format("opentype"), url('../../../cb1130234589/resources/fonts/NothingYouCouldSay.ttf') format('truetype'), url('../../../cb1130234589/resources/fonts/NothingYouCouldSay.svg') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
如果我将 *.woff 添加到图像 servlet 映射,那么 servlet 会抱怨文件的 MIME 类型不被理解。
有什么办法可以让 Jawr 不处理这些特定的特定 URL?
我试图理解两件事:
SimpleDateFormat不宽松)这是代码
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TestDate {
public static void main(String[] args) throws Exception {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
format.setLenient(false);
Date date = format.parse("01/01/13"); // Since this only has a 2 digit year, I would expect an exception to be thrown
System.out.println(date); // Prints Sun Jan 01 00:00:00 GMT 13
Calendar cal = Calendar.getInstance();
cal.setTime(date);
System.out.println(cal.get(Calendar.YEAR)); // Prints 13
}
}
Run Code Online (Sandbox Code Playgroud)
如果有什么不同,我在 Ubuntu 上使用 java …