我有一个我在Tomcat中部署的Web应用程序.我想保护url路径管理/*下的所有页面.
我已将容器管理的安全性设置为web.xml文件中的下一个片段:
<security-role>
<role-name>administrator</role-name>
</security-role>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>AdministrationPanel</web-resource-name>
<url-pattern>/administration/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>administrator</role-name>
<role-name>member</role-name>
</auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
我在$ CATALINA_HOME/conf/tomcat-users.xml中
<user username="userA" password="userA" roles="administrator"/>
Run Code Online (Sandbox Code Playgroud)
一切都很好.我得到一个登录框,我可以作为userA验证自己.
但是,我希望能够通过使用Web应用程序直接存储新用户,更改用户密码等.
是否有可能告诉tomcat以其他方式获取用户,密码和角色?例如,从数据库中检索它们的类.
我使用struts-html生成表单字段.
例如:
<%@ taglib prefix="html" uri="/WEB-INF/taglibs/struts-html.tld" %>
<html:text property="email" styleId="email" size="44"/>
Run Code Online (Sandbox Code Playgroud)
产生:
<input type="text" name="email" size="44" value="" id="email">
Run Code Online (Sandbox Code Playgroud)
如上所示,生成的输入标记未关闭.这导致我的html无效.
struts-html.tld包括:
<tlibversion>1.2</tlibversion>
<jspversion>1.1</jspversion>
<shortname>html</shortname>
<uri>http://struts.apache.org/tags-html</uri>
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么生成的输入没有关闭?有更新的版本吗?哪里可以下载?
我试过用:
<html:html xhtml="true">
Run Code Online (Sandbox Code Playgroud)
其呈现为:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
Run Code Online (Sandbox Code Playgroud)
但是,我的输入标签会保持渲染不已闭合.
解:
使用标签:
<html:xhtml/>
Run Code Online (Sandbox Code Playgroud)
注意:如果您像我一样使用Tiles,请直接在包含的jsp中使用它.它不是从您的基本模板文件继承的.
注意:在xhtml模式下,您不能在html:form标记内使用sytleId.这不是问题,因为自动生成id属性来存储bean的名称.
在下面的代码中.我期待的是真的,但我却变得虚假了.我错过了什么?
var text = "Sentence $confirmationlink$ fooo";
alert(placeHolderExists(text,'confirmationlink'); // alerts false
function placeHolderExists(text,placeholdername) {
var pattern = new RegExp('\$'+placeholdername+'\$');
return pattern.test(text);
}
Run Code Online (Sandbox Code Playgroud) 我想org.apache.commons.validator.GenericValidator在我的GWT Web应用程序的视图类中使用该类.我已经读过,我必须明确告诉我打算使用这个外部库.我想在我的App.gwt.xml工作中添加下一行.
<inherits name='org.apache.commons.validator.GenericValidator'/>
我收到下一个错误:
Loading inherited module 'org.apache.commons.validator.GenericValidator'
[ERROR] Unable to find 'org/apache/commons/validator/GenericValidator.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 13: Unexpected exception while processing element 'inherits'
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:239)
at com.google.gwt.dev.cfg.ModuleDefSchema$BodySchema.__inherits_begin(ModuleDefSchema.java:354)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.util.xml.HandlerMethod.invokeBegin(HandlerMethod.java:223)
at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.startElement(ReflectiveParser.java:270)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1339)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at …Run Code Online (Sandbox Code Playgroud) 是否有可能在ie6中显示⇓实体?它正在每个浏览器中显示但不是IE 6.我正在编写标记,例如:
<span>⇓</span>
Run Code Online (Sandbox Code Playgroud) 我有一个带国家/地区呼叫代码的精选html标签.
<select name="countryCallingCode" id="countryCallingCode">
<option value="1"><span class="name">Afghanistan</span><span class="code">+93</span></option>
<option value="2"><span class="name">Albania</span><span class="code">+355</span></option>
<option value="3"><span class="name">Algeria</span><span class="code">+213</span></option>
</select>
Run Code Online (Sandbox Code Playgroud)
我希望名称左对齐,代码右对齐.演示文稿应如下所示:
Afghanistan +93
Albania +355
Algeria +213
Run Code Online (Sandbox Code Playgroud)
我已经介绍了使用CSS实现这一目标的span元素.
select#countryCallingCode span.name {text-align: left;}
select#countryCallingCode span.code {text-align: right;}
Run Code Online (Sandbox Code Playgroud)
上面的代码,不起作用.而且,span元素似乎在XHTML 1.0 strict的html选项标记内无效.
任何的想法?
这不起作用.Firebug并没有抛出任何错误.
HTML:
<table>
<tr><td>BookA</td><td><a href="javascript:deleteRow($(this));" class="red">Delete</a></td></tr>
<tr><td>BookB</td><td><a href="javascript:deleteRow($(this));" class="red">Delete</a></td></tr>
<tr><td>BookC</td><td><a href="javascript:deleteRow($(this));" class="red">Delete</a></td></tr>
<tr><td>BookD</td><td><a href="javascript:deleteRow($(this));" class="red">Delete</a></td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
function deleteRow(ref) {
$(ref).parent().parent().remove();
}
Run Code Online (Sandbox Code Playgroud)
如果可能的话,我想使用内联javascript的解决方案
我想知道如何使用javax.jdo.Query限制结果数量
我已经尝试了setRange函数但没有成功.
这是我目前的解决方法
Object query_result = q.execute(locationId);
if(query_result!=null && ((List<BaseObject>) query_result).size()>0)
return (PokerSession) ((List<BaseObject>) query_result).get(0);
return null;
Run Code Online (Sandbox Code Playgroud) 我想使用Google Shortener API.我想使用google api java客户端库发布请求并解析JSON响应.
接下来,我发布了我尝试过的代码:
import java.io.IOException;
import net.sf.json.JSONObject;
import com.google.api.client.googleapis.GoogleHeaders;
import com.google.api.client.googleapis.GoogleTransport;
import com.google.api.client.googleapis.json.JsonCParser;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonHttpContent;
import com.google.api.client.util.GenericData;
public class GoogleShortener {
public static final String GOOGL_URL = "https://www.googleapis.com/urlshortener/v1/url";
public static void main(String[] args) {
// setup up the HTTP transport
HttpTransport transport = GoogleTransport.create();
// add default headers
GoogleHeaders defaultHeaders = new GoogleHeaders();
transport.defaultHeaders = defaultHeaders;
transport.defaultHeaders.put("Content-Type", "application/json");
transport.addParser(new JsonCParser());
// build the HTTP GET request and URL
GenericData …Run Code Online (Sandbox Code Playgroud) 来自 Grails 3.1.9 发布说明:
集成测试端口集成和功能测试现在在随机端口上运行,而不是默认情况下与应用程序相同的端口。这是为了在应用程序已经运行时避免端口冲突问题。需要更改对端口进行硬编码的集成测试,以使用标有 @Integration 的测试的 serverPort 属性
我通常使用以下方式获取集成测试网址
import grails.util.Holders
...
..
.
def urlWhereIntegrationAppIsRunning = Holders.grailsApplication.config.grails.serverURL
然后在我的
application.yml
我有类似的东西:
test:
server:
port: 8090
grails:
serverURL: http://localhost:8090
如何在集成测试中使用 Grails 3.19 获取我的集成测试运行的 URL(服务器 URL 和随机端口)?
基于 Marco 的回答,我做了一个 Trait 来封装集成测试运行的 url。我在测试 API 的 Spock 规范中实现了这个特性。
import org.springframework.beans.factory.annotation.Value
trait TIntegrationServerUrl {
@Value('${local.server.port}')
Integer serverPort
String integrationServerUrl() {
"http://localhost:$serverPort"
}
}
Run Code Online (Sandbox Code Playgroud) javascript ×2
css ×1
grails ×1
grails-3.1 ×1
gwt ×1
java ×1
jquery ×1
regex ×1
security ×1
struts ×1
struts-html ×1
tomcat ×1
xhtml ×1