请看下面的代码.显示四个文本框.
如果我在前面的文本框中输入"1"和"2",它们就像我预期的那样以逗号分隔的"1,2"绑定.
但是,如果我输入"2001/01/01"和"2001/01/02"在其他两个盒子中被绑定"2001/01/01"."2001/01/01"只是令人惊讶地结合在一起.第一个参数似乎优先绑定.
我想知道在哪里定义了规范(HTTP或SpringMVC或......?),以便深入和准确地理解.有人能帮我吗?
Form
public class SampleForm {
private String name;
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
JSP
<form:form modelAttribute="form" method="post">
<form:input path="name" />
<form:input path="name" />
<form:input path="date" />
<form:input path="date" />
<p>
<input type="submit" name="register" value="register" />
</p>
</form:form>
Run Code Online (Sandbox Code Playgroud) 我需要从Tomcat中的servlet(或过滤器)访问Manager,以通过自定义会话ID加载自定义会话.
回答你的下一个问题:为什么我需要它.Flash中存在一个旧错误,导致它从IE发送cookie,而不是从当前浏览器发送.所以,如果我在FF中并且我正在尝试使用SWFUpload上传文件,那么我最终会遇到错误的会话和错误.
我想将magic参数添加到应该覆盖默认(错误)会话ID的POST,然后加载自定义会话而不是Tomcat加载的会话.我不能使用URL重写,因为cookie首先被解析,当flash从IE发送错误的cookie时,Tomcat不会尝试从url重写的地址加载会话.
我很感激任何其他提示如何从上下文访问管理器或原始问题的解决方案.
谢谢,Juriy
在我的代码中,我做了如下:
我对这种持久化方法的行为感到困惑.
请帮帮我.
代码如下:
//My Service......
@Service("myService")
@Transactional
public class MyServiceImpl implements MyService {
@Transactional(rollbackFor = { Throwable.class })
public void updateCourse(final Course course) throws MyServiceException {
------
------
CourseEntity courseEntity = courseDao.findById(course.getId());
populateCourseEntity(courseEntity, course);
courseDao.update(courseEntity);
}
}
//CourseDao.....
public class CourseDaoImpl implements CourseDao {
--------
public void update(final T entity) throws MyDaoException {
if (entity != null) {
this.entityManager.persist(entity);
}
else {
String errMsg = "Object to be updated cannot be null.";
throw new MyDaoException(errMsg); …Run Code Online (Sandbox Code Playgroud) 我正在使用新的JSF2 <h:link>标记,嵌套<f:param>链接到使用get请求的页面.但是,会话ID(cid)通过链接的查询parambeters传播到新页面.
可以用一个人来抑制会话传播<h:link>吗?即.网址中没有cid =#?
我知道这个问题是主观的,但是由于OpenID库页面列出了许多库,我认为可能会做出一些尝试来提名最好的一个或两个,就以下方面而言:
我很感激任何使用过任何OpenID Java库的人的回答
我继承了一年前由某人开发的JSF项目,该项目不再适用于我的公司,代码很难理解.其中很多似乎是由IDE自动生成的,尤其是类的getter和setter.实际上,每个私有字段都有关联的getter和setter,即使它们未在项目中的任何位置引用.
我想在尝试理解项目之前摆脱所有这些无用的代码,但鉴于它是一个JSF项目,bean的属性可能在xhtml文件中引用,因此在使用"show references"命令时不会显示.
有没有办法知道哪些方法真的没用,以便安全地删除它们?
我使用eclipse但是每个允许这样做的工具都会让我感到很放松!
我正在浏览Java文档以寻找C++的STL的Java等价物Queue,但我发现的只是一个被调用的接口Queue和一堆我无法做到的实现的实现.
Java是否有一个实现Queue只是一个FIFO数据结构而没有添加花里胡哨?我只需要enqueue,dequeue以及front运营和数据结构应该允许重复.
这几天我正在使用 spring mvc 进行一些测试,但有一个问题。对于要测试的基本应用程序,我选择本教程: http://loianegroner.com/2010/09/extjs-spring-mvc-3-and-hibernate-3-5-crud-datagrid-example/ 我已下载该示例和一切都按预期工作。问题是当我尝试添加另一个控制器时。看来我添加的文件没有被扫描。
我的 web.xml 文件:
<servlet>
<servlet-name>extjs-crud-grid-spring-hibernate</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/app-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>extjs-crud-grid-spring-hibernate</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
/WEB-INF/spring/app-config.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
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">
<!-- Scans the classpath of this application for @Components to deploy as beans -->
<context:component-scan base-package="com.loiane" />
<!-- Configures the @Controller programming model -->
<mvc:annotation-driven />
<!-- misc -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- Configures Hibernate - …Run Code Online (Sandbox Code Playgroud) 我试图将此scriptlet代码转换为JSF类.
视图代码
<f:view>
<h:form binding="#{jsfSocketClient.form}">
<h:outputText binding="#{jsfSocketClient.text}"/>
</h:form>
</f:view>
Run Code Online (Sandbox Code Playgroud)
和java代码
private HtmlForm form = new HtmlForm();
private HtmlOutputText text = new HtmlOutputText();
public HtmlForm getForm()
{
System.out.println("instance: "+FacesContext.getCurrentInstance().getResponseWriter());
ResponseWriter writer = (FacesContext.getCurrentInstance()).getResponseWriter();
try{
int character;
Socket socket = new Socket("127.0.0.1", 8765);
InputStream inSocket = socket.getInputStream();
OutputStream outSocket = socket.getOutputStream();
String str = "Hello!\n";
byte buffer[] = str.getBytes();
outSocket.write(buffer);
char characters = 0;
while ((character = inSocket.read()) != -1) {
text.setValue((char)character);
//writer.write((char)character);
//characters += (char)character;
}
//text.setValue(characters);
if(str.equalsIgnoreCase("bye"))
{ …Run Code Online (Sandbox Code Playgroud) JSR-303中有正则表达式验证(javax.validation)。例如:
@Pattern(regexp="[\w_\\.]+")
private String username;
Run Code Online (Sandbox Code Playgroud)
值无效(与正则表达式不匹配)时显示的默认消息类似于“必须匹配{regex}”。但是用户不了解正则表达式,因此向他们展示它是无关紧要的。一种选择是仅显示“用户名包含非法字符”,在大多数情况下可能会很好。但是最好显示哪个字符是错误的。
使用正则表达式无法直接实现-它匹配还是不匹配。您必须定义缺少某些组件的其他模式,或者尝试从字符串中删除字符直到匹配为止,然后将这些字符显示给用户。
总体而言。另一个问题是如何使用javax.validation实现此目的。
因此,总结一下问题:
如何使用javax.validation显示有问题的字符,以使消息看起来像“字符?,*和$是非法的”