我为Tiles设置了配置,但它只加载扩展页面,这是主要内容,但不是header.jsp或footer.jsp。它也不会出错。
我认为它不会在action-servlet.xml中应用Tiles的配置,而只会应用其他视图解析器......
我不知道为什么......我做错了什么?
action-servlet.xml文件
<tiles-definitions>
<definition name="base" template="/WEB-INF/views/template/base.jsp">
<put-attribute name="header" value="/WEB-INF/views/template/header.jsp" />
<put-attribute name="footer" value="/WEB-INF/views/template/footer.jsp"/>
</definition>
<definition name="/" extends="base">
<put-attribute name="content" value="/WEB-INF/views/contents/boardList.jsp" />
</definition>
</tiles-definitions>
layout.xml
<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<div id="container">
<!-- header -->
<tiles:insertAttribute name="header" />
<!-- contents -->
<tiles:insertAttribute name="content"/>
<!-- footer -->
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>
<html>
<head>
base.jsp
import React from 'react';
import {Field, FieldArray, reduxForm} from 'redux-form'
let renderEmailField = ({input, label, type, meta: {touched, error}}) =>
<fieldset>
<label>{label}</label>
<div>
<input {...input} name="email" type="text" className="form-control" />
{touched && error && <span>{error}</span>}
</div>
</fieldset>
let renderEmails = ({fields, meta: {submitFailed, error}}) =>
<div>
{fields.map((email, index) =>
<div className="row form-group" key={index}>
<div className="col-6">
<Field
name={email}
component={renderEmailField}
label={`Email Address`}
/>
</div>
<div className="col">
{index > 2 &&
<a href onClick={(e) => {e.preventDefault(); fields.remove(index)}}>X</a>
}
</div>
<div className="col">
{submitFailed && error &&
<span className="error">{error}</span>
}
</div>
</div>
)}
<div className="row form-group">
<div className="col">
<p>
<a href onClick={(e) => {e.preventDefault(); fields.push()}}>Add Email</a>
</p>
</div>
</div>
</div>
class RaterInviteForm extends React.Component {
handleSubmit(data) {
// stuff
}
render() {
const { submitting } = this.props
return (
<div className="RaterInviteForm">
<h1>Invites</h1>
<form className="form" onSubmit={this.props.handleSubmit(this.handleSubmit.bind(this))}>
<FieldArray name="emails" component={renderEmails} />
<div className="form-group">
<button type="submit" disabled={submitting} className="btn btn-primary">Send Invitations</button>
</div>
</form>
</div>
);
}
}
const validate = values => {
const errors = {}
console.log('validate')
if (!values.emails || !values.emails.length) {
errors.emails = {_error: 'At least one email must be entered'}
}
else {
let emailsArrayErrors = []
if (emailsArrayErrors.length) {
errors.emails = emailsArrayErrors
}
}
return errors
}
RaterInviteForm = reduxForm({
form: 'emailsForm',
initialValues: {
emails: ['', '', '']
},
validate
})(RaterInviteForm)
...
答案 0 :(得分:0)
您的扩展匿名定义中没有包含页眉,页脚属性。修改layout.xml,如下所示,
<tiles-definitions>
<definition name="base" template="/WEB-INF/views/template/base.jsp">
<put-attribute name="header" value="" />
<put-attribute name="footer" value=""/>
</definition>
<definition name="/" extends="base">
<put-attribute name="content" value="/WEB-INF/views/contents/boardList.jsp" />
<put-attribute name="header" value="/WEB-INF/views/template/header.jsp" />
<put-attribute name="footer" value="/WEB-INF/views/template/footer.jsp"/>
</definition>
</tiles-definitions>