我有一个Spring(4.1.6.RELEASE)MVC项目,其中有一个映射到的控制器/home
,但我的问题是它也被调用了类似于/home.html
或的路径/home.do
我的配置是:
web.xml:
<servlet>
<servlet-name>main</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>main</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
main-servlet.xml:
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- ... -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
Run Code Online (Sandbox Code Playgroud)
HomeController.java:
@Controller
@RequestMapping({"/", "/home"})
public class HomeController {
@RequestMapping(method = RequestMethod.GET)
public String doGet(Model model) {
// ...
return "home";
}
}
Run Code Online (Sandbox Code Playgroud)
正如类似问题所示:
我尝试添加以下配置:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="useDefaultSuffixPattern" value="false" />
</bean> …
Run Code Online (Sandbox Code Playgroud) OneToOne
我正在尝试在共享相同 PK 的两个实体之间建立关系:
+----------------------------------+ +----------------+-----------------+
| Item | | Stats |
+----------------+-----------------+ +----------------+-----------------+
| reference (PK) | other data... | | reference (PK) | other data... |
+----------------+-----------------+ +----------------+-----------------+
| ABCD | ... | | ABCD | ... |
| XYZ | ... | | XYZ | ... |
+----------------+-----------------+ +----------------+-----------------+
Run Code Online (Sandbox Code Playgroud)
其中Stats.reference
FK 为Item.reference
:
alter table Stats
add constraint FK_8du3dv2q88ptdvthk8gmsipsk
foreign key (reference)
references Item;
Run Code Online (Sandbox Code Playgroud)
该结构是从以下带注释的类生成的:
@Entity
public class Item {
@Id
private String reference;
@OneToOne(mappedBy …
Run Code Online (Sandbox Code Playgroud) 我有一个模板,它是编辑某些元素的表单的一部分。要执行的操作因包含它的页面而异。所以我将 action 方法作为参数传递:
<ui:param name="option" value="#{someOptionBean}" />
...
<ui:include src="/WEB-INF/jsf/value-edit.xhtml">
<ui:param name="controllerParam" value="#{optionController}" />
<ui:param name="elementParam" value="#{option}" />
<ui:param name="actionParam" value="updateOption" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)
或者:
<ui:param name="property" value="#{somePropertyBean}" />
...
<ui:include src="/WEB-INF/jsf/value-edit.xhtml">
<ui:param name="controllerParam" value="#{propertyController}" />
<ui:param name="elementParam" value="#{property}" />
<ui:param name="actionParam" value="updateProperty" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)
并且value-edit.xhtml
有一个命令按钮:
<p:commandButton value="Update" action="#{controllerParam[actionParam](elementParam)}" />
Run Code Online (Sandbox Code Playgroud)
到目前为止一切正常。
我的问题是现在操作方法没有相同数量的参数。他们是:
public void updateOption(Option option) { ... }
public void updateProperty(Item item, Prop property) { ... }
Run Code Online (Sandbox Code Playgroud)
所以我现在希望能够定义动作参数以具有以下内容:
<ui:param name="actionParam" value="updateOption(option)" />
<ui:param name="actionParam" value="updateProperty(item, property)" />
Run Code Online (Sandbox Code Playgroud)
或类似的东西: …
我包含来自同一模板文件的模板片段。文档的“ 8.1 包括模板片段 - 定义和引用片段”部分指出:
" ::domselector " 或 " this::domselector " 包含来自同一模板的片段。
如果我没有误解,我应该能够如下引用该片段:th:include="this :: contentB"
或者th:include=":: contentB"
但只有完整的参考th:include="test-fragment :: contentB"
对我有用。
这是示例代码:
HomeController.java
@Controller
class HomeController {
@RequestMapping({ "/", "index", "home" })
String index(Model model) {
return "test";
}
}
Run Code Online (Sandbox Code Playgroud)
测试.html
<!DOCTYPE html>
<html>
<head></head>
<body>
<ul th:replace="test-fragment :: contentA" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
测试片段.html
<!DOCTYPE html>
<html>
<head></head>
<body>
<ul th:fragment="contentA">
<li th:each="idx : ${#numbers.sequence(1,4)}" th:switch="${idx}">
<th:block th:case="1"
th:include="test-fragment :: contentB"
th:with="strVar = 'One'"/>
<th:block th:case="2" …
Run Code Online (Sandbox Code Playgroud) webpack stats 中的 immutable、dev... 是什么意思?
使用 webpack 构建项目时,我会得到一些统计信息,例如:
Asset Size Chunks Chunk Names
index.html 2.31 KiB [emitted]
js/main.920a0304.js 4.93 MiB 0 [emitted] [immutable] main
js/main.920a0304.js.map 5.42 MiB 0 [emitted] [dev] main
Run Code Online (Sandbox Code Playgroud)
我很好奇[immutable]
,[dev]
到底代表什么。但是,不幸的是,我找不到描述这些概念的地方。我在 webpack 文档中进行了 google 搜索和搜索,但没有成功。
有没有关于这个的文件?
编辑:
我在github上打开了一个与此相关的问题:https : //github.com/Microsoft/TypeScript/issues/21265
看来这{ ...other: xother }
不是有效的JS,TS,代码,甚至都不应该编译。
原始问题:
让我们假设以下示例:
const values = { a: "1", b: "2", c: "3", d: "4" };
const { a: va, b: vb, ...other } = values;
Run Code Online (Sandbox Code Playgroud)
其中va
为property分配了新的变量名a
。
根据TypeScript规范,对其余属性执行相同操作是否有效...other
?就像是:
const { a: va, b: vb, ...other: vother } = values;
Run Code Online (Sandbox Code Playgroud)
我知道它有效,我已经对其进行了测试(在线测试)。但是我无法找到它的定义位置。
引用属性重命名的文档示例始终显示“正常”情况:TypeScript手册-变量声明。规范语法引用了规范中BindingPattern
未描述(或我错过了)的:TypeScript Spec。
我的第一印象是它不是很有用,因为...other
它已经是一个自定义变量名。但这有效。而且我很想知道它的具体定义是什么,或者这仅仅是一个极端的案例(我想不是)。
我正在使用Liferay 6.1开发一个portlet Liferay MVC famework
.我用的时候
<liferay-ui:search-container />
Run Code Online (Sandbox Code Playgroud)
Eclipse总是向我显示以下警告消息
SearchContainer是一种原始类型.
SearhcContainer<R>
应参数化对泛型类型的引用
JSP代码片段:
<%
List<User> users = UserLocalServiceUtil.search(...);
%>
<liferay-ui:search-container>
<liferay-ui:search-container-results
results="<%= users %>"
total="<%= users.size() %>"
/>
<liferay-ui:search-container-row
className="com.liferay.portal.model.User"
keyProperty="userId"
modelVar="userVar">
<liferay-ui:search-container-column-text
name="name"
value="<%= userVar.getFullName() %>" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
Run Code Online (Sandbox Code Playgroud)
我搜索了很多例子.我已将它们导入我的工作区.当使用search-container
标记时,它们也会向我显示相同的警告消息.
一个例子是此portlet:事件列出的portlet
中/docroot/html/eventlisting/view.jsp Eclipse中显示我同样的警告.
我没有在stackoverflow中找到任何搜索解决方案,也没有找到google.我在jsp中发现了很多对警告的引用,但是当使用某些标记时发生警告时没有.
如果可能,我不想禁用JSP验证或使用一些@SuppressWarnings
.
我真的想知道在使用这个taglib时是否有正确的方法来避免JSP中的这个警告.
我正在使用
- Liferay 6.1.1 CE GA2
- Eclipse Luna Release 4.4.0
提前致谢
我正在尝试使用该length()
方法打印出a的长度,String
但我不断收到标题中提到的错误.我是Java新手,我认为这个方法是构建到IDE(Eclipse)中的.
import class JumbleHelper {
String word;
public JumbleHelper(String jumbleWord)
{
word = jumbleWord;
}
public static void main(String[] args)
{
JumbleHelper str1 = new JumbleHelper("maybe");
System.out.println(str1.length());
}
}
Run Code Online (Sandbox Code Playgroud)